Go to @Snapey site, I don't remember the link, but he has an article about double pagination. I found it http://novate.co.uk/using-multiple-pagination-links-on-one-page/
Apr 30, 2018
4
Level 7
Query two different models and merging with pagination
I have two Models Conversation and DirectEnquiry that I would like to query together and show in the same list of results with pagination.
This is where I am at:
$conversations = $user->conversations()
->inbox($filters)
->with('job')
->paginate(20);
$directEnquiries = $user->directEnquiries()->paginate(20);
$conversations = $conversations->merge($directEnquiries)->sortBy(function($item) {
return $item->updated_at;
})->reverse();
This works fine until it hits the pagination method at the bottom of the view
{!! $conversations->links() !!}
I am getting the following error message:
ErrorException in Macroable.php line 74:
Method links does not exist.
I've tried playing with unions also but as these are two different models that won't work.
Any ideas?
Thanks!
Ralph
Please or to participate in this conversation.