Skip to content

Commit

Permalink
Merge pull request #8
Browse files Browse the repository at this point in the history
Allow to specify the `perPage` limit from the query param
  • Loading branch information
hschimpf committed Nov 9, 2023
2 parents 6b34fcd + 315edad commit 642b9d7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Actions/PaginateResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ public function __construct(
) {}

public function handle(Builder $query, Closure $next): Collection | LengthAwarePaginator {
$perPage = $this->request->integer('perPage', $query->getModel()->getPerPage());

return $next($this->request->boolean('all')
? $query->get()
: $query->paginate()->withQueryString()
: $query->paginate($perPage)->withQueryString()
);
}

Expand Down

0 comments on commit 642b9d7

Please sign in to comment.