@Prez Thanks for the reply! The problem is that it returns all the results as it is right now. I would like to paginate the events and was thinking a possible way would be to define the relationship in the route and paginate it from there. Right now, I can only paginate the User in the route, but one user can have 1000 events and they would all be shown.
Mar 4, 2016
5
Level 7
Call relationship in route?
Hi Artisans,
I followed Jeffs series on activity feed. Right now, I have in my route this:
$userevent = User::with('event')->get();
Then in my view, I have something like this:
@foreach ($userevent as $user)
@foreach($user->activity as $event)
@include ("activity.type.{$event->name}")
@endforeach
@endforeach
Instead of doing two foreach loops. I would like to refactor it to only have one loop. I would call the $userevent->activity in the route instead and thus control pagination of how many are passed through.
However when I try doing $userevent->activity in the route I get error that it's undefined property. What would be a good practice to call the relationship from the route?
Please or to participate in this conversation.