/** * Get the current page for the request. * * @param int $lastPage * @return int */ protected function calculateCurrentPage($lastPage) { $page = $this->factory->getCurrentPage(); if (is_numeric($page) && $page > $lastPage) { return $lastPage > 0 ? $lastPage : 1; } return $this->isValidPageNumber($page) ? (int) $page : 1; }
/** * Get a paginator for an ungrouped statement. * * @param \Pagination\Factory $paginator * @param int $perPage * @param array $columns * @return \Pagination\Paginator */ protected function ungroupedPaginate($paginator, $perPage, $columns) { $total = $this->query->getPaginationCount(); $page = $paginator->getCurrentPage($total); $this->query->forPage($page, $perPage); return $paginator->make($this->get($columns)->all(), $total, $perPage); }