roseriyadh's avatar

Remove Eloquent Limit off queries

Good day, I have a list of users that are total of 4000, and all of them i need to return them in pagination with few where clause and other filters, what I'm experiencing is the total in the pagination is 500 only and i don't know how to remove this limit for good.

Can you guys help me?

0 likes
4 replies
LaryAI's avatar
Level 58

To remove the limit on the number of results returned by Eloquent queries, you can use the paginate method with a custom page size. By default, Laravel's pagination uses a page size of 15. To retrieve all 4000 users without any limit, you can set the page size to a large number or use a value that is greater than the total number of users.

Here's an example of how you can modify your query to remove the limit:

$users = User::where('column', 'value')
    ->paginate(4000); // Set the page size to a large number

// Or

$users = User::where('column', 'value')
    ->simplePaginate(4000); // Set the page size to a large number

// You can also use a value greater than the total number of users, like 9999

return view('users.index', compact('users'));

By setting the page size to a large number or a value greater than the total number of users, you will retrieve all the users without any limit in the pagination.

Snapey's avatar

There is no limit for you to remove.

PovilasKorop's avatar

@roseriyadh that number 500 is set somewhere in your code, or in some package that you use, please show the code for us, or search for "500" in your project and you will find where to change it.

Please or to participate in this conversation.