Laravel pagination: Change page parameter name

Posted 3 years ago by SergioGregorutti

Hi all,

I want to make a simple change on the Laravel pagination.

By default I get a "?page=x" URI but I need this: "?pag=x".

How can I make this change? I read the documentation and I found this:

Customizing The Paginator URI

The setPath method allows you to customize the URI used by the paginator when generating links. For example, if you want the paginator to generate links like http://example.com/custom/url?page=N, you should pass custom/url to the setPath method:

Route::get('users', function () {
    $users = App\User::paginate(15);

    $users->setPath('custom/url');

    //
});

But it is no so clear for me.

Can someone help me?

Thanks in advance!

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.