File tree Expand file tree Collapse file tree 2 files changed +6
-19
lines changed
Http/Controllers/Operations Expand file tree Collapse file tree 2 files changed +6
-19
lines changed Original file line number Diff line number Diff line change @@ -79,10 +79,12 @@ public function search()
7979 $ length = (int ) request ()->input ('length ' );
8080 $ search = request ()->input ('search ' );
8181
82- // we get the max length from the page length menu possibilities
83- $ maxLength = $ this ->crud ->maxPageLength ();
84-
85- $ length = $ maxLength === -1 ? $ length : ($ length > $ maxLength ? $ maxLength : $ length );
82+ // check if length is allowed by developer
83+ if ($ length && ! in_array ($ length , $ this ->crud ->getPageLengthMenu ()[0 ])) {
84+ return response ()->json ([
85+ 'error ' => 'Unknown page length. ' ,
86+ ], 400 );
87+ }
8688
8789 // if a search term was present
8890 if ($ search && $ search ['value ' ] ?? false ) {
Original file line number Diff line number Diff line change @@ -218,21 +218,6 @@ public function getDefaultPageLength()
218218 return $ this ->getOperationSetting ('defaultPageLength ' ) ?? config ('backpack.crud.operations.list.defaultPageLength ' ) ?? 25 ;
219219 }
220220
221- /**
222- * Get the higher limit from the page length menu.
223- * -1 means "All" so if present it means no limit.
224- */
225- public function maxPageLength (): int
226- {
227- $ pageLengthMenu = $ this ->getPageLengthMenu ();
228-
229- if (in_array (-1 , $ pageLengthMenu [0 ])) {
230- return -1 ;
231- }
232-
233- return (int ) max ($ pageLengthMenu [0 ]);
234- }
235-
236221 /**
237222 * If a custom page length was specified as default, make sure it
238223 * also show up in the page length menu.
You can’t perform that action at this time.
0 commit comments