How to Override Default Pagination Number in Laravel

Hello Artisan,

In this quick Laravel tutorial, I will show you how to override the default paginate number in Laravel. Laravel shows us per 15 rows as a default paginate number, but sometimes we need to change it like 5 or 10 or 12, etc. How we can do that override default paginate number in Laravel?

Laravel gives us $perPage to get override default to paginate number in Laravel. Using this variable, we can change the default paginate number in Laravel. Let's see the below example:

Put this $perPage in a model where you want to change.

class Chat extends Model
{
  use SoftDeletes;
  
  protected $perPage = 10;
  
  //code goes here
}

 

Read also: Laravel 8.x Custom Pagination Example Tutorial

 

Hope it can help you to change your default paginate number in Laravel.

 

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