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.

 

author-image
Facebook Github
A web enthusiastic, a self-motivated full-stack software engineer from Dhaka, Bangladesh with experience in developing applications using Laravel , React and Vue js