Skip to content

Commit

Permalink
Update LengthAwarePaginator.php (#15870)
Browse files Browse the repository at this point in the history
Ran into minor problem using multiple LengthAwarePaginators on a single page with alternate 'pageName' properties. Traced problem to the attached proposed change.

When checking the current page for a LengthAwarePaginator instance, any non-default pageName is not sent to resolveCurrentPage and as such 1 is always returned (unless pageName of 'page' is used).
  • Loading branch information
jivemonkey2000 authored and taylorotwell committed Oct 13, 2016
1 parent 30abf1c commit 6976bf1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Illuminate/Pagination/LengthAwarePaginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ public function __construct($items, $total, $perPage, $currentPage = null, array
$this->perPage = $perPage;
$this->lastPage = (int) ceil($total / $perPage);
$this->path = $this->path != '/' ? rtrim($this->path, '/') : $this->path;
$this->currentPage = $this->setCurrentPage($currentPage, $this->lastPage);
$this->currentPage = $this->setCurrentPage($currentPage, $this->pageName);
$this->items = $items instanceof Collection ? $items : Collection::make($items);
}

/**
* Get the current page for the request.
*
* @param int $currentPage
* @param int $lastPage
* @param string $pageName
* @return int
*/
protected function setCurrentPage($currentPage, $lastPage)
protected function setCurrentPage($currentPage, $pageName)
{
$currentPage = $currentPage ?: static::resolveCurrentPage();
$currentPage = $currentPage ?: static::resolveCurrentPage($pageName);

return $this->isValidPageNumber($currentPage) ? (int) $currentPage : 1;
}
Expand Down

0 comments on commit 6976bf1

Please sign in to comment.