Skip to content

Commit

Permalink
fix #14387 pagination issue in the newest release (#14389)
Browse files Browse the repository at this point in the history
  • Loading branch information
themsaid authored and taylorotwell committed Jul 20, 2016
1 parent 6195211 commit 4835c0a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Illuminate/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,14 +482,15 @@ public function lists($column, $key = null)
*/
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
{
$page = $page ?: Paginator::resolveCurrentPage($pageName);

$perPage = $perPage ?: $this->model->getPerPage();

$query = $this->toBase();

$total = $query->getCountForPagination();

$results = $total ? $this->forPage(
$page = $page ?: Paginator::resolveCurrentPage($pageName),
$perPage = $perPage ?: $this->model->getPerPage()
)->get($columns) : [];
$results = $total ? $this->forPage($page, $perPage)->get($columns) : [];

return new LengthAwarePaginator($results, $total, $perPage, $page, [
'path' => Paginator::resolveCurrentPath(),
Expand Down

0 comments on commit 4835c0a

Please sign in to comment.