Reputation: 1146
I need a custom pagination but in my case, i do not use eloquent for fetching data. I use an API where i fetch data.
I've been dealing with Pagination class, but as far as i know, it takes a collection and paginate it. That's not what i need.
What i need is creating a paginate object based on a subset of records gotten by a search query. Let's say such query has a total of 10000 records and I only get an array of 50 items, so each paginate has 50 elements. So, i need to create the pagination links based on this info.
Is there any way of accomplish it?
EDIT:
$models = array('total' => $n_results,
'per_page' => 30,
'current_page' => 1,
'last_page' => ceil($n_results/30),
'next_page' => "******",
'prev_page' => "******",
'from' => 1,
'to' => 30,
'data' => $items);
Upvotes: 1
Views: 389
Reputation: 142
Based on what I understood here what I would do:
1- if you cannot ask the limit and offset for each call of the API and the API provides all the results to you at once but you want to show them 50 at a time, then I would create a temp_table and insert the data to it and then it's like it's on my own database then I would be able to sort,limit and offset by myself.
2- if the total result is not that much (like less than 500) and you want the user to not be overwhelmed by all the results together and you wanna show it to them 50 results at a time or 20 results at a time you can load all the result in blade by hide their element. (it's not what I would recommend but it would do the trick if you don't want a temp_table)
Upvotes: 0