I have users
that have multiple restaurants
, then each restaurant
has comments
.
So when a user
logs in, I would like to show a list of all the comments
from restaurants
related to the user.
I am using laravel 5.1
What I have so far is:
$restaurants = $user->restaurants;
$comments = null;
foreach ($restaurants as $restaurant) {
if (!$comments){
$comments = $restaurants->comments();
} else{
$comments = $comments->merge($restaurant->comments());
}
}
$rows = $comments->paginate(15);
$count = $comments->count();
I get a BadMethodCallException
, I think I am not doing this the laravel way.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire