Skip to content

Commit

Permalink
fix: added limit to smartPaginate method
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexFN authored Jun 1, 2021
1 parent 481730f commit 6835ce5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Eloquent/BaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,14 @@ public function firstOrFail($columns = ['*'])
* Paginate the given query by 'limit' request parameter
* @return mixed
*/
public function smartPaginate()
public function smartPaginate($perPage = null)
{
$limit = (int) request()->input(
config('awesio-repository.smart_paginate.request_parameter'),
config('awesio-repository.smart_paginate.default_limit')
);

if ($limit === 0) $limit = config('awesio-repository.smart_paginate.default_limit');
if ($limit === 0) $limit = ($perPage) ?: config('awesio-repository.smart_paginate.default_limit');

$maxLimit = config('awesio-repository.smart_paginate.max_limit');

Expand All @@ -263,4 +263,4 @@ public function orderBy($column, $direction = 'asc')

return $this;
}
}
}

0 comments on commit 6835ce5

Please sign in to comment.