laravel's collection pagination
// 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);