LaravelDaily/laravel-tips

Pivot Table with Extra Relations (https://github.com/LaravelDaily/laravel-tips#pivot-table-with-extra-relations)

abirkulov opened this issue · 4 comments

Thank you for such usefull information. It would be nice if you add advice that tells how to eager load relations on a pivot table to avoid "n + 1 queries" problem. There's a usefull package which resolve this problem . See for more information - https://github.com/ajcastro/eager-load-pivot-relations

@AbirkulovSherali it's quite a rare case, in my opinion. In this repository, I accept Pull Request with Laravel Tips, if you write it, but this wouldn't be on my list of very useful tips.

@PovilasKorop but still, the case in "Pivot Table with Extra Relations" section is a quite rare case itself. If there is a section how to add an extra relation on a pivot table, then there should be a section describing how to eager load that relation (of course if there is an ability to do that). Thank you.

@AbirkulovSherali I guess you're right, but it's not something I would personally add. If you want to add it, please submit a Pull Request and I may accept it.