Skip to content

Commit 6835ce5

Browse files
authored
fix: added limit to smartPaginate method
1 parent 481730f commit 6835ce5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Eloquent/BaseRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,14 @@ public function firstOrFail($columns = ['*'])
234234
* Paginate the given query by 'limit' request parameter
235235
* @return mixed
236236
*/
237-
public function smartPaginate()
237+
public function smartPaginate($perPage = null)
238238
{
239239
$limit = (int) request()->input(
240240
config('awesio-repository.smart_paginate.request_parameter'),
241241
config('awesio-repository.smart_paginate.default_limit')
242242
);
243243

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

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

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

264264
return $this;
265265
}
266-
}
266+
}

0 commit comments

Comments
 (0)