Here you go: https://laracasts.com/discuss/channels/eloquent/paginate-eloquent-collection
You can't simply run this in your view. You have to create the paginator object in your controller and return that to the view ;)
Hello,
I have code like this below:
@foreach($user->activities as $activity) <tr> <td>{{$activity->id}}</td> <td>{{$activity->duration}}</td> <td>{{$activity->date}}</td> <td>{{$transaction->created_at->diffForHumans()}}</td> <td>{{$transaction->updated_at->diffForHumans()}}</td> </tr> @endforeach
I want to paginate this piece of code. I am not accessing activities model from controller here.
Please let me know how can we directly paginate the code in blade template.
Regards, Palak
Here you go: https://laracasts.com/discuss/channels/eloquent/paginate-eloquent-collection
You can't simply run this in your view. You have to create the paginator object in your controller and return that to the view ;)
Please or to participate in this conversation.