Answer the question
In order to leave comments, you need to log in
How to do in Laravel Eager Loading User Favorited??
There is a bunch of news. The user can like them. 15 news are displayed on 1 page of news. Each one should show whether the user liked the news or not.
How to make eager loading so that the load is loaded and attached to the model? (the point is to make 1 request instead of 15)
Answer the question
In order to leave comments, you need to log in
$user = User::with('favorites')->first();
'Favorites' is the name of the method that implements the association
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question