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)