Skip to content

Instantly share code, notes, and snippets.

@salipro4ever
Created December 8, 2018 17:12
Show Gist options
  • Save salipro4ever/e77d373325bef9ddd528bf55bd3ed360 to your computer and use it in GitHub Desktop.
Save salipro4ever/e77d373325bef9ddd528bf55bd3ed360 to your computer and use it in GitHub Desktop.
You can add this method as Collection method in AppServiceProvider. just add this in boot method.
if (!Collection::hasMacro('AppServiceProvider')) {
Collection::macro('paginate',
function ($perPage = 15, $page = null, $options = []) {
$page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
return (new LengthAwarePaginator(
$this->forPage($page, $perPage), $this->count(), $perPage, $page, $options))
->withPath('');
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment