Beispiel #1
0
 /**
  * @inheritdoc
  */
 public function getCount()
 {
     return (int) $this->paginator->count();
 }
 /**
  * @param Paginator $paginator
  * @param           $paginatorCountReturn
  */
 protected function countExpectations(Paginator $paginator, $paginatorCountReturn)
 {
     $paginator->count()->shouldBeCalled()->willReturn($paginatorCountReturn);
 }
 /**
  * @param $paginated
  * @return array
  */
 protected function buildPaginationResponse(\Illuminate\Pagination\Paginator $paginated)
 {
     $data = ['items' => $paginated->getItems(), 'page' => $paginated->getCurrentPage(), 'per_page' => $paginated->getPerPage(), 'page_results' => $paginated->count(), 'total_results' => $paginated->getTotal()];
     return $data;
 }
Beispiel #4
0
 /**
  * @param Paginator $paginator
  * @return array
  */
 protected function getPagination(Paginator $paginator)
 {
     $currentPage = $paginator->getCurrentPage();
     $lastPage = $paginator->getLastPage();
     $links = [];
     if ($currentPage > 1) {
         $links['previous'] = $paginator->getUrl($currentPage - 1);
     }
     if ($currentPage < $lastPage) {
         $links['next'] = $paginator->getUrl($currentPage + 1);
     }
     $pagination = [];
     $pagination['total'] = $paginator->getTotal();
     $pagination['count'] = $paginator->count();
     $pagination['per_page'] = $paginator->getPerPage();
     $pagination['current_page'] = $currentPage;
     $pagination['total_pages'] = $lastPage;
     $pagination['links'] = $links;
     return $pagination;
 }
Beispiel #5
0
 /**
  * @param Paginator $paginatorData
  * @param $data
  * @return mixed
  */
 public function respondWithPagination($paginatorData, $data)
 {
     $data = array_merge($data, ['paginator' => ['total_count' => count($paginatorData->items()), 'total_pages' => ceil(count($paginatorData->items()) / $paginatorData->perPage()), 'current_page' => $paginatorData->currentPage(), 'limit' => $paginatorData->count(), 'next_page_url' => $paginatorData->nextPageUrl()]]);
     return $this->respond($data);
 }