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.