Level 102
Try this
$ids = $pagination_query->items()->pluck('id');
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
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?
Ty!
Try this
$ids = $pagination_query->items()->pluck('id');
Please or to participate in this conversation.