/**
  * @param LengthAwarePaginator $paginator
  * @param $bootstrapVersion
  * @return string
  */
 protected static function _render(LengthAwarePaginator $paginator, $bootstrapVersion)
 {
     if ($paginator->lastPage() <= 1) {
         return '';
     }
     switch ($bootstrapVersion) {
         case 4:
             $defaultPresenter = 'pagination::bootstrap-4';
             break;
         default:
             $defaultPresenter = '';
     }
     return $paginator->render($defaultPresenter);
 }
 /**
  * Get the last page from the paginator.
  *
  * @return int
  */
 protected function lastPage()
 {
     return $this->paginator->lastPage();
 }
 /**
  * Get the last page.
  *
  * @return int
  */
 public function getLastPage()
 {
     return $this->paginator->lastPage();
 }
示例#4
0
 /**
  * Determine if the underlying paginator being presented has pages to show.
  *
  * @return bool
  */
 public function hasPages()
 {
     return $this->paginator->lastPage() > 1;
 }
 /**
  * Get all urls in an array.
  *
  * @param \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator
  * @param bool                                                  $full      Return the full version of the URL in for the first page
  *                                                                         Ex. /users/page/1 instead of /users
  *
  * @return array
  */
 public function allUrls(LengthAwarePaginator $paginator, $full = false)
 {
     if (!$paginator->hasPages()) {
         return [];
     }
     $urls = [];
     for ($page = 1; $page <= $paginator->lastPage(); ++$page) {
         $urls[] = $this->pageUrl($page, $full);
     }
     return $urls;
 }
示例#6
0
 /**
  * @param LengthAwarePaginator $articles Articles to change to an ArticleCollection
  * @return ArticleCollection
  */
 private function paginate(LengthAwarePaginator $articles)
 {
     return new ArticleCollection($articles->items(), $articles->total(), $articles->perPage(), $articles->currentPage(), ['lastPage' => $articles->lastPage(), 'path' => $articles->resolveCurrentPath()]);
 }
 /**
  * Will result in an array with a paginator
  *
  * @param LengthAwarePaginator $items   The paginated items
  * @param array                $data    The data
  * @param array                $headers The headers that should be send with the JSON-response
  *
  * @return \Illuminate\Http\JsonResponse The JSON-response with the paginated results
  */
 protected function respondWithPagination(LengthAwarePaginator $items, $data, $headers = [])
 {
     $data = array_merge($data, ['pagination' => ['total_count' => $items->total(), 'total_pages' => $items->lastPage(), 'current_page' => $items->currentPage(), 'limit' => $items->perPage()]]);
     return $this->respond($data, $headers);
 }