From 6835ce5ba805a7075fb64fd7db36093a95e2b6ad Mon Sep 17 00:00:00 2001 From: AlexFN <49072623+AlexFN@users.noreply.github.com> Date: Tue, 1 Jun 2021 16:34:52 +0300 Subject: [PATCH] fix: added limit to smartPaginate method --- src/Eloquent/BaseRepository.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Eloquent/BaseRepository.php b/src/Eloquent/BaseRepository.php index 1ce2d61..61ac3ee 100644 --- a/src/Eloquent/BaseRepository.php +++ b/src/Eloquent/BaseRepository.php @@ -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'); @@ -263,4 +263,4 @@ public function orderBy($column, $direction = 'asc') return $this; } -} \ No newline at end of file +}