當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Paginator::getPerPage方法代碼示例

本文整理匯總了PHP中Paginator::getPerPage方法的典型用法代碼示例。如果您正苦於以下問題:PHP Paginator::getPerPage方法的具體用法?PHP Paginator::getPerPage怎麽用?PHP Paginator::getPerPage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Paginator的用法示例。


在下文中一共展示了Paginator::getPerPage方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: simpleRendeArray

 /**
  * create pagination with only previous and next buttons
  *
  * @return array
  */
 public function simpleRendeArray()
 {
     $array = [];
     $count = $this->paginator->getCount();
     $url = $this->path;
     $current = $this->paginator->getCurrentPage();
     // create appends string
     $appends = $this->createAppendString($this->paginator->getAppends());
     // create fragments string
     $fragments = $this->createFragmentsString($this->paginator->getFragments());
     if ($count < $this->paginator->getPerPage()) {
         $limit = 1;
     } else {
         $limit = ceil($count / $this->paginator->getPerPage());
     }
     if ($this->isAvaibleCurrentPage($current) && $current > 1) {
         $previous = $current - 1;
         $array[] = $this->buildChieldString('Previous', $this->buildFullChieldStrind($url, $appends), $this->pageName, $fragments, $previous);
     }
     if ($this->isAvaibleCurrentPage($current) && $current < $limit) {
         $next = $current + 1;
         $array[] = $this->buildChieldString('Next', $this->buildFullChieldStrind($url, $appends), $this->pageName, $fragments, $next);
     }
     return $array;
 }
開發者ID:AnonymPHP,項目名稱:Anonym-Database,代碼行數:30,代碼來源:Render.php

示例2: respondWithPagination

 /**
  * @param Paginator $items
  * @param $data
  * @return \Illuminate\Http\JsonResponse
  */
 protected function respondWithPagination($items, $data)
 {
     $data = array_merge($data, ['paginator' => ['total_count' => $items->getTotal(), 'total_pages' => ceil($items->getTotal() / $items->getPerPage()), 'current_page' => $items->getCurrentPage(), 'limit' => $items->getPerPage()]]);
     return $this->respond($data);
 }
開發者ID:juaguz,項目名稱:apigenerator,代碼行數:10,代碼來源:ApiController.php

示例3: respondWithPagination

 /**
  * @param Paginator $elements
  * @param $data
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function respondWithPagination(Paginator $elements, $data)
 {
     $data = array_merge($data, ['paginator' => ['totalCount' => $elements->getTotal(), 'totalPages' => ceil($elements->getTotal() / $elements->getPerPage()), 'currentPage' => $elements->getCurrentPage(), 'limit' => $elements->getPerPage()]]);
     return $this->respond($data);
 }
開發者ID:unknownworlds,項目名稱:postgre2mongo,代碼行數:11,代碼來源:BaseApiController.php


注:本文中的Paginator::getPerPage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。