Skip to content

Commit

Permalink
https://github.com/yajra/laravel-datatables/issues/2493
Browse files Browse the repository at this point in the history
Hard Limit in Config (for Pagination)
  • Loading branch information
saaiful committed Jan 16, 2021
1 parent e0b416d commit aecfefe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/QueryDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,8 @@ 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 = ($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]);
Expand Down
7 changes: 7 additions & 0 deletions src/config/datatables.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,11 @@
'options' => 0,
],

/**
* Maximum records per page
* Set 0 for unlimited record
* Do not use value under 10 if you are not using laravel-datatables-html
*/
'max_records_per_page' => 100,

];

0 comments on commit aecfefe

Please sign in to comment.