I have two models : Task and Comment
In my user profil I want to display tasks and comments sort by created date.
For this I do :
$timeline_array = $customer->comments;
$timeline_array = $timeline_array->toBase()->merge($customer->tasks);
//sort timeline event
$timeline_array = $timeline_array->sortByDesc(function($timeline_event){
return $timeline_event->created_at;
});
And I foreach my array in my view. It's work fine but if I have too much comments or tasks it's will be a big request so I want to add a paginator.
How can I do it ?
If I had a $timeline_array->paginate(5);
at the end I get the error :
Method Illuminate\Support\Collection::paginate does not exist.
And I think it's not fixing my problem because I load all the comments and tasks before I paginate it.
Somebody have an idea/solution ?