Created
June 24, 2021 14:38
-
-
Save im-noob/bd8d079fac34f735d5c0751ee1a90758 to your computer and use it in GitHub Desktop.
AddPaginatinSuportTOCollection Laravel .php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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