Middleware that automatically sets pagination for all endpoints.
You add middleware in App\Http\Kernel
protected $middleware = [
...
Heseya\Pagination\Http\Middleware\Pagination::class,
];
or to specific route in router
Route::get(...)->middleware(Pagination::class);
Now when you send parameter limit
/products?limit=50
you can use pagination.per_page
config key to set pagination limit
public function index()
{
return Product::paginate(Config::get('pagination.per_page'));
}
composer require heseya/laravel-pagination
php artisan vendor:publish --tag=pagination