LeachCreative's avatar

API Endpoint Pagination

I'm wanting to use a bunch of GET params to build a query using the query builder for my API. The result will end up being paginated, however when I go to the next page, all of my GET params are gone. Suggestions?

0 likes
1 reply
SyedAbuthahir's avatar
Level 4

Laravel paginator has appends method to achieve this. Read Appending To Pagination Links on Displaying Pagination Results.

Example

$params = request->only(['role','status']);
$users = App\User::paginate(15)->appends($params);
3 likes

Please or to participate in this conversation.