There is a setPath public function available on the AbstractPaginator class; you can use this to optionally set a path. Similarly there is a setPageName method which allows you to change the default page query param key
How to change path and query string when using LengthAwarePaginator?
I created a custom LengthAwarePaginator using this answer from SO:
https://stackoverflow.com/a/63392687/19815685
But there were 2 issues: first the path was not correct, but I was able to change that by hardcoding the URL like so:
$path = 'my-path';
$options = ['path' => $path];
return new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options);
But I couldn't find out how to change the query string. Now it shows:
example.com/my-path?page=3
Is it possible to use the LengthAwarePaginator to get the current path (if not specified, it will use the root URL) without hardcoding it, and also change the default query string from page to something else?
@Ligonsker if you are not using the standard page parma, then you need to pass the custom page name to the resolver, e.g.
Paginator::resolveCurrentPage('pageName')
Please or to participate in this conversation.