Skip to content

Commit

Permalink
Merge pull request #5503 from Laravel-Backpack/add-a-way-to-limit-ent…
Browse files Browse the repository at this point in the history
…ries

Validate length parameter server side
  • Loading branch information
pxpm committed Apr 16, 2024
2 parents 648c417 + 05ee35c commit f576488
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/app/Http/Controllers/Operations/ListOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ public function search()
$length = (int) request()->input('length');
$search = request()->input('search');

// check if length is allowed by developer
if ($length && ! in_array($length, $this->crud->getPageLengthMenu()[0])) {
return response()->json([
'error' => 'Unknown page length.',
], 400);
}

// if a search term was present
if ($search && $search['value'] ?? false) {
// filter the results accordingly
Expand Down

0 comments on commit f576488

Please sign in to comment.