Skip to content

Instantly share code, notes, and snippets.

@Merazsohel
Created December 30, 2021 11:03
Show Gist options
  • Save Merazsohel/f5b3d9ca6144ea3dbb8f33ea2408baf3 to your computer and use it in GitHub Desktop.
Save Merazsohel/f5b3d9ca6144ea3dbb8f33ea2408baf3 to your computer and use it in GitHub Desktop.
Laravel Custom LengthAwarePaginator
$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