Skip to content

Commit

Permalink
Merge pull request #2843 from paul45/patch-1
Browse files Browse the repository at this point in the history
add $segment parameter in pager call by Model.php
  • Loading branch information
lonnieezell authored Apr 22, 2020
2 parents 27dc596 + c54a7b1 commit 0eea4b2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1126,10 +1126,11 @@ public function chunk(int $size, Closure $userFunc)
* @param string $group Will be used by the pagination library
* to identify a unique pagination set.
* @param integer $page Optional page number (useful when the page number is provided in different way)
* @param integer $segment Optional URI segment number (if page number is provided by URI segment)
*
* @return array|null
*/
public function paginate(int $perPage = null, string $group = 'default', int $page = 0)
public function paginate(int $perPage = null, string $group = 'default', int $page = 0, int $segment = 0)
{
$pager = \Config\Services::pager(null, null, false);
$page = $page >= 1 ? $page : $pager->getCurrentPage($group);
Expand All @@ -1138,7 +1139,7 @@ public function paginate(int $perPage = null, string $group = 'default', int $pa

// Store it in the Pager library so it can be
// paginated in the views.
$this->pager = $pager->store($group, $page, $perPage, $total);
$this->pager = $pager->store($group, $page, $perPage, $total, $segment);
$perPage = $this->pager->getPerPage($group);
$offset = ($page - 1) * $perPage;

Expand Down

0 comments on commit 0eea4b2

Please sign in to comment.