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


PHP Paginator::getCollection方法代碼示例

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


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

示例1: getNext

 /**
  * @inheritdoc
  */
 public function getNext()
 {
     $last = $this->paginator->getCollection()->last();
     if (is_null($last)) {
         return 0;
     }
     return (int) $last->id;
 }
開發者ID:larapackage,項目名稱:api,代碼行數:11,代碼來源:LaravelCollection.php

示例2: paginatedCollection

 public function paginatedCollection(Paginator $paginator, $transformer = null, $resourceKey = null)
 {
     $paginator->appends(\Request::query());
     $resource = new Collection($paginator->getCollection(), $this->getTransformer($transformer), $resourceKey);
     $resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
     return $this->manager->createData($resource)->toArray();
 }
開發者ID:huglester,項目名稱:larasponse,代碼行數:7,代碼來源:Fractal.php

示例3:

 function it_gets_the_next_position(Paginator $paginator, Collection $collection)
 {
     $next = 4;
     $model = new \stdClass();
     $model->id = $next;
     $paginator->getCollection()->shouldBeCalledTimes(1)->willReturn($collection);
     $collection->last()->shouldBeCalledTimes(1)->willReturn($model);
     $this->getNext()->shouldReturn($next);
 }
開發者ID:larapackage,項目名稱:api,代碼行數:9,代碼來源:LaravelCollectionSpec.php

示例4: withPaginator

 /**
  * Respond with a paginator, and a transformer.
  *
  * @param Paginator $paginator
  * @param callable|\League\Fractal\TransformerAbstract $transformer
  * @param string $resourceKey
  * @param array $meta
  * @return \Illuminate\Http\Response
  */
 public function withPaginator(Paginator $paginator, $transformer, $resourceKey = null, $meta = [])
 {
     $resource = new Collection($paginator->getCollection(), $transformer, $resourceKey);
     $resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
     foreach ($meta as $metaKey => $metaValue) {
         $resource->setMetaValue($metaKey, $metaValue);
     }
     $rootScope = $this->manager->createData($resource);
     return $this->withArray($rootScope->toArray());
 }
開發者ID:ryanmcoble,項目名稱:remedy,代碼行數:19,代碼來源:Response.php

示例5: answerOkByPager

 static function answerOkByPager(Paginator $paginator)
 {
     if ($paginator->getLastPage() == $paginator->getCurrentPage()) {
         $next_page = null;
     } else {
         $next_page = $paginator->getCurrentPage();
     }
     $next_page_url = $next_page ? \Request::url() . '?page=' . $next_page : null;
     return parent::json(['meta' => ['code' => 200], 'pagination' => ['next_url' => $next_page_url, 'next_page' => $next_page], 'data' => $paginator->getCollection()->toArray()], 200, [], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
 }
開發者ID:korchasa,項目名稱:laravel-jsonio,代碼行數:10,代碼來源:JsonResponse.php

示例6: transformPaginator

 /**
  * @param AbstractPaginator|LengthAwarePaginator|Paginator $paginator
  * @return \League\Fractal\Resource\Collection
  */
 protected function transformPaginator($paginator)
 {
     $collection = $paginator->getCollection();
     $resource = new Collection($collection, $this->getTransformer(), $this->resourceKeyCollection);
     $resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
     return $resource;
 }
開發者ID:osvaldino,項目名稱:warehouse,代碼行數:11,代碼來源:FractalPresenter.php

示例7: formatResponse

 protected function formatResponse(Paginator $paginator, BaseTransformer $transformer = null)
 {
     $data = $paginator->getCollection();
     if (!is_null($transformer)) {
         $data = $this->transformData($data, $transformer);
     }
     $this->appendsQueryString($paginator);
     return ["data" => $data, "meta" => ["pagination" => $this->getPagination($paginator)]];
 }
開發者ID:ratiw,項目名稱:api,代碼行數:9,代碼來源:ApiController.php


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