Skip to content

Commit 5e92712

Browse files
authored
Merge pull request #13 from spelcaster/fix-paginate
fix paginate perPage
2 parents d0584b3 + 352b0db commit 5e92712

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/BaseRepository.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public function lists($value, $key = null)
227227
* @param null $page
228228
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
229229
*/
230-
public function paginate($perPage, $columns = ['*'], $pageName = 'page', $page = null)
230+
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
231231
{
232232
$perPage = $perPage ?: $this->getDefaultPerPage();
233233

@@ -764,11 +764,11 @@ public function removeCriteriaOnce($key)
764764
*/
765765
protected function getDefaultPerPage()
766766
{
767-
if (is_numeric($this->perPage) && $this->perPage > 0) {
768-
return $this->perPage;
769-
}
767+
$perPage = (is_numeric($this->perPage) && $this->perPage > 0)
768+
? $this->perPage
769+
: $this->makeModel(false)->getPerPage();
770770

771-
return config('repository.perPage', $this->makeModel(false)->getPerPage());
771+
return config('repository.perPage', $perPage);
772772
}
773773

774774
}

0 commit comments

Comments
 (0)