Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get list of ids from pagination query of the current page?

I have 1 pagination query for every:

$pagination_query = Table1::...->paginate(100);

then I have a second query that needs to use the list of ids from the pagination query:

$second_query = Table2::whereIn('id', $list_of_ids_from_pagination_query);

How can I get the list of ids only from the paginated page so that I get 100 ids and not thousands of ids which will end up in too many bound variables error?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Ty!

>Solution :

You can use something like this .

$ids = Table1::...->paginate(100)->pluck('id');


$second_query = Table2::wherein('id', $ids);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading