当前位置: 首页>>代码示例>>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;未经允许,请勿转载。