Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

SergioGregorutti's avatar

Laravel pagination: Change page parameter name

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!

0 likes
2 replies
abusalameh's avatar
Level 30

@SergioGregorutti

those are the parameters to the Paginate Method

public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)

you can specify your paginate method like this

$users = App\User::paginate(15,['*'],'pag');

forget to add [''] .. add it :) instead of ''

and it will work :)

13 likes

Please or to participate in this conversation.