Skip to content

Instantly share code, notes, and snippets.

@im-noob
Created June 24, 2021 14:38
Show Gist options
  • Save im-noob/bd8d079fac34f735d5c0751ee1a90758 to your computer and use it in GitHub Desktop.
Save im-noob/bd8d079fac34f735d5c0751ee1a90758 to your computer and use it in GitHub Desktop.
AddPaginatinSuportTOCollection Laravel .php
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,
]
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment