File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Http/Controllers/Operations Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,11 @@ 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 );
86+
8287 // if a search term was present
8388 if ($ search && $ search ['value ' ] ?? false ) {
8489 // filter the results accordingly
Original file line number Diff line number Diff line change @@ -218,6 +218,21 @@ 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+
221236 /**
222237 * If a custom page length was specified as default, make sure it
223238 * also show up in the page length menu.
You can’t perform that action at this time.
0 commit comments