diff --git a/src/QueryDataTable.php b/src/QueryDataTable.php index e44440b7..49e9d83d 100644 --- a/src/QueryDataTable.php +++ b/src/QueryDataTable.php @@ -594,7 +594,10 @@ public function limit(callable $callback) */ public function paging() { - $limit = (int) $this->request->input('length') > 0 ? $this->request->input('length') : 10; + $max_records_per_page = $this->config->get('datatables.max_records_per_page', 0); + $limit = (int) $this->request->input('length') > 0 ? $this->request->input('length') : 10; + $limit = ($max_records_per_page > 0 && $limit > $max_records_per_page) ? $max_records_per_page : $limit; + if (is_callable($this->limitCallback)) { $this->query->limit($limit); call_user_func_array($this->limitCallback, [$this->query]); diff --git a/src/config/datatables.php b/src/config/datatables.php index ed2e36f7..270b7670 100644 --- a/src/config/datatables.php +++ b/src/config/datatables.php @@ -119,4 +119,10 @@ 'options' => 0, ], + /** + * Maximum records per page + * Set 0 for unlimited record. + */ + 'max_records_per_page' => 100, + ];