CodepadME / laravel-tricks

The source code for the Laravel Tricks website
http://laravel-tricks.com
MIT License
966 stars 298 forks source link

Model relationship table question. #20

Closed cojocaru closed 10 years ago

cojocaru commented 10 years ago

Hi ,

I have one question that is not only specific to this project but you also used it, so maybe you can shortly help me or point to some resource. I can figure out how the pivot table tag_trick is managing the many to many relationship. I found in Trick model the : protected $with = [ 'tags', 'categories', 'user' ]; (which is related to eager loading), and the standard belongsToMany methods, but I am wondering is this enough to create a new pivot table? e.g. subcategories, is it enough to set the belong to relationship, and laravel itself is managing it?

In short how the application knows about pivot table tag_trick?

thanks in advance, and if its off topic you can close it.