Skip to content

Instantly share code, notes, and snippets.

@WendellAdriel
Created February 8, 2017 12:25
Show Gist options
  • Save WendellAdriel/e9a015d43f8c6748ac1c2fc19257f930 to your computer and use it in GitHub Desktop.
Save WendellAdriel/e9a015d43f8c6748ac1c2fc19257f930 to your computer and use it in GitHub Desktop.
Simple many-to-many laravel 5 example
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Client extends Model
{
public function tickets()
{
return $this->belongsToMany('App\Ticket', 'clients_tickets');
}
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Ticket extends Model
{
public function clients()
{
return $this->belongsToMany('App\Client', 'clients_tickets');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment