Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you change the page name for Paginator?

Current Paginator is using ?page=N, but I want to use something else. How can I change so it's ?sida=N instead?

I've looked at Illuminate\Pagination\Environment and there is a method (setPageName()) there to change it (I assume), but how do you use it?

In the Paginator class there is a method the change the base url (setBaseUrl()) in the Environment class, but there is no method for setting a page name. Do I really need to extend the Paginator class just to be able to change the page name?

like image 446
Marwelln Avatar asked Mar 29 '14 12:03

Marwelln


2 Answers

Just came across this same issue for 5.1 and you can pass the page name like this:

Post::paginate(1, ['*'], 'new-page-name');
like image 87
Kevin Jung Avatar answered Oct 10 '22 10:10

Kevin Jung


Just like you said you can use the setPageName method:

Paginator::setPageName('sida');

You can place that in app/start/global.php.

like image 30
Jason Lewis Avatar answered Oct 10 '22 09:10

Jason Lewis