ekrist1's avatar

Eloquent query with pagination

I have implementet query string filtering using the laracast session (https://laracasts.com/series/eloquent-techniques/episodes/4).

I´m able to add pagination to the result, but how can I add pagination together with the query string? Now the next_url shows http://laravel.dev/api/getcontacts?page=2 regardless your have a query string like: http://laravel.dev/api/getcontacts?keyword=t

Getcontact controller:

  $contacts = Contact::filter($filters)->paginate(2);

   return response()->json($contacts);

Query string code: https://github.com/laracasts/Dedicated-Query-String-Filtering

0 likes
1 reply
ekrist1's avatar

added:

$contacts->appends(Request()->all())->links();

seems to work

Please or to participate in this conversation.