laravel-cross-eloquent-search icon indicating copy to clipboard operation
laravel-cross-eloquent-search copied to clipboard

Retain querystring values during pagination

Open mulongokato opened this issue 3 years ago • 4 comments

Hello, I love this package so much, it does not play nice with pagination options like withQueryString()

mulongokato avatar Sep 24 '22 10:09 mulongokato

This worked as a temporary solution

$data = new \Illuminate\Pagination\LengthAwarePaginator( $data->getCollection(), $data->total(), $data->perPage(), $data->currentPage(), [ 'path' => request()->url(), 'query' => $request->query() ] );

where $data is the result from Search::new()->add(...

mulongokato avatar Sep 24 '22 14:09 mulongokato

I Think this is the same Issue as this one posted to the Laravel-Ide-Helper Project.

https://github.com/barryvdh/laravel-ide-helper/issues/1144

jandermannderkann avatar Oct 19 '22 16:10 jandermannderkann

I don't understand the problem. Could you give an example so I can reproduce the problem?

pascalbaljet avatar Dec 10 '22 16:12 pascalbaljet

This solution worked for me:

$results->appends($request->query());

Here is a link to the documentation: https://laravel.com/docs/9.x/pagination#appending-query-string-values.

lucacastelnuovo avatar Dec 20 '22 15:12 lucacastelnuovo