From 7d32bf9a7cbd65b3b29bbbdf9acce132b7057a73 Mon Sep 17 00:00:00 2001 From: Lukas Heller Date: Fri, 21 Feb 2025 20:29:04 +0100 Subject: [PATCH] fix: manual pagination not triggered --- src/Concerns/PaginateIndex.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Concerns/PaginateIndex.php b/src/Concerns/PaginateIndex.php index 2b23cd7..e635b4c 100644 --- a/src/Concerns/PaginateIndex.php +++ b/src/Concerns/PaginateIndex.php @@ -20,13 +20,13 @@ public function pageName(string $pageName) return $this; } - public function paginateFromRequest(Request $request) + public function paginateFromRequest(Request $request, $perPage = null) { - if (($request->has('page') || $request->has('perPage')) == false) { + if (($request->has('page') || $request->has('perPage')) == false && $perPage === null) { return $this; } - $perPage = $request->get('perPage', $this->perPage); + $perPage = $perPage ?? $request->get('perPage', $this->perPage); return $this->query() ->paginate($perPage, ['*'], $this->pageName)