📅  最后修改于: 2022-03-11 14:54:25.188000             🧑  作者: Mango
// this goes to -> \app\Providers\AppServiceProvider -> boot function
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
Collection::macro('paginate', function($perPage, $total = null, $page = null, $pageName = 'page') {
$page = $page ?: LengthAwarePaginator::resolveCurrentPage($pageName);
return new LengthAwarePaginator(
$this->forPage($page, $perPage),
$total ?: $this->count(),
$perPage,
$page,
[
'path' => LengthAwarePaginator::resolveCurrentPath(),
'pageName' => $pageName,
]
);
});
// this goes to controller. collection->paginate(1);
$event->paginate(1);