0
votes

I have query with laravel which returns my results and paginate() at the end, problem is when i foreach it to collect all ids in array i get first page only.

Is there a way to get those before paginate so i dont have to run the query twice?

$clients  = Client::apply($data, $dataArray)->ModelJoinCall()->orderBy($this->sortby, $this->orderby)->paginate(30); 
1

1 Answers

0
votes

There is no way to do that, because paginate is use Sql limit to retrieve datas, let's assume you are in page one, you will retrieve first 30 records from database,next if you are in page two, then you get 30 to 60 records from database.

there is no Trouble to have another sql to get all ids.

or if you database won't have too much datas. you can retrieve them all in one page and make a pagination effects use javascript and html