Created
December 30, 2021 11:03
-
-
Save Merazsohel/f5b3d9ca6144ea3dbb8f33ea2408baf3 to your computer and use it in GitHub Desktop.
Laravel Custom LengthAwarePaginator
This file contains 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
$this->paginate('Here will go your array'); | |
public function paginate($items, $perPage = 50, $page = null, $options = []) | |
{ | |
$page = $page ?: (Paginator::resolveCurrentPage() ?: 1); | |
$items = $items instanceof Collection ? $items : Collection::make($items); | |
return new LengthAwarePaginator( | |
$items->forPage($page, $perPage), | |
$items->count(), | |
$perPage, | |
$page, | |
["path" => route("route name goes here", | |
[ | |
"status" => '----' | |
] | |
)] | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment