How To Customize Page Key Name In Laravel Pagination

Hello artisan, In this tutorial, I will show you how to customize the ‘page’ key name in ‘Laravel Pagination’. You know that, in laravel pagination, the default pagination key name is "page". But in this example, i will show you how we can customize and set our own page name in laravel. So using this tutorial, you will able to make your own laravel custom pagination links.

Let's see the example code:

//the default
Order::paginate(5, [‘*’], ‘page’);

//change it like
Order::paginate(5, [‘*’], ‘order_page’);

 

You can also use like that:

$orders = Order::paginate(5);

$orders->setPageName(‘custom_page_key’);

 

Read also: How to Install and Use MongoDB in Laravel Lumen

 

Hope it can help you.

 

#laravel