Finalized many to many relationship

This commit is contained in:
2021-09-05 02:51:33 +02:00
parent f4c030934a
commit d1d2198ef5
7 changed files with 77 additions and 35 deletions

View File

@@ -11,6 +11,6 @@ class Beer extends Model
public function list()
{
return $this->belongsToMany(BeerList::class, 'beer_list_pivot', 'list_id', 'beer_id');
return $this->belongsToMany(BeerList::class, 'beer_list_pivot', 'beer_id', 'list_id');
}
}

View File

@@ -21,6 +21,7 @@ class BeerList extends Model
public function beer()
{
return $this->belongsToMany(Beer::class, 'beer_list_pivot', 'beer_id', 'list_id');
return $this->belongsToMany(Beer::class, 'beer_list_pivot', 'list_id', 'beer_id')
->withTimestamps();
}
}