当前位置: 首页>>代码示例>>PHP>>正文


PHP LengthAwarePaginator::getCollection方法代码示例

本文整理汇总了PHP中Illuminate\Pagination\LengthAwarePaginator::getCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP LengthAwarePaginator::getCollection方法的具体用法?PHP LengthAwarePaginator::getCollection怎么用?PHP LengthAwarePaginator::getCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Pagination\LengthAwarePaginator的用法示例。


在下文中一共展示了LengthAwarePaginator::getCollection方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createPagedCollection

 protected function createPagedCollection(LengthAwarePaginator $paginator, TransformerAbstract $transformer)
 {
     $data = $paginator->getCollection();
     $collection = new Collection($data, $transformer);
     $collection->setPaginator(new IlluminatePaginatorAdapter($paginator));
     return $this->fractal->createData($collection)->toArray();
 }
开发者ID:Gamespectre,项目名称:spectator-api,代码行数:7,代码来源:FractalDataTrait.php

示例2: respondWithPaginator

 /**
  * @param Paginator $data
  * @param TransformerAbstract $transformer
  * @param array $headers
  * @return \Illuminate\Http\JsonResponse
  */
 public function respondWithPaginator(LengthAwarePaginator $data, TransformerAbstract $transformer, $headers = [])
 {
     $manager = new Manager();
     $manager->setSerializer(new ArraySerializer());
     $resource = new Collection($data->getCollection(), $transformer);
     $resource->setPaginator(new IlluminatePaginatorAdapter($data));
     $response = $manager->createData($resource)->toArray();
     return $this->respond(['post' => $this->_request->all(), 'data' => $response['data'], 'meta' => $response['meta'], 'error' => ['global' => '']], $headers);
 }
开发者ID:Buuntu,项目名称:Laravel-API,代码行数:15,代码来源:ApiController.php

示例3: getData

 /**
  * Get data .
  *
  * @param null $perPage
  * @return array
  */
 public function getData($perPage = null)
 {
     $source = $this->getSource();
     $items = $source['rows'];
     $offSet = @$_GET['page'] * $perPage - $perPage;
     $itemsForCurrentPage = array_slice($items, $offSet, $perPage, true);
     $paginator = new LengthAwarePaginator($itemsForCurrentPage, count($source['rows']), $perPage);
     return ['columns' => $this->source['columns'], 'rows' => $paginator->getCollection(), 'total' => $paginator->total()];
 }
开发者ID:parfumix,项目名称:table-manager,代码行数:15,代码来源:Collection.php

示例4: __construct

 /**
  * Constructor.
  * @param Collection|LengthAwarePaginator $collection
  * @param string $class - optional
  */
 public function __construct($collection, $class = null)
 {
     if ($collection instanceof LengthAwarePaginator) {
         $this->paginator = $collection;
         $this->items = $collection->getCollection();
     } else {
         $this->items = $collection;
     }
     if ($class) {
         $this->setClass($class);
     }
 }
开发者ID:breachofmind,项目名称:birdmin,代码行数:17,代码来源:Table.php

示例5: transformPaginated

 public function transformPaginated(LengthAwarePaginator $paginator)
 {
     $collection = $paginator->getCollection();
     try {
         $transformer = TransformerFactory::makeForCollection($collection);
         $resource = new Collection($collection, $transformer);
         $resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
         return $this->manager->createData($resource)->toArray();
     } catch (\OutOfRangeException $e) {
         $emptyResource = new Collection([], []);
         $emptyResource->setPaginator(new IlluminatePaginatorAdapter($paginator));
         return $this->manager->createData($emptyResource)->toArray();
     }
 }
开发者ID:efrane,项目名称:transfugio,代码行数:14,代码来源:EloquentWorker.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: formateHatoeasPaged

 /**
  * @param LengthAwarePaginator $paged
  *
  * @return PaginatedRepresentation
  */
 public function formateHatoeasPaged(LengthAwarePaginator $paged)
 {
     $request = \App::make('request');
     $params = array_merge($request->route()[2], $request->all());
     return new PaginatedRepresentation(new CollectionRepresentation($paged->getCollection(), null, $request->path()), $request->route()[1]['as'], $params, $paged->currentPage(), $paged->perPage(), $paged->lastPage(), 'page', 'per_page', true, $paged->total());
 }
开发者ID:greatwitenorth,项目名称:lumen-doctrine-hateoas,代码行数:11,代码来源:Controller.php

示例8: wrapPager

 public static function wrapPager(LengthAwarePaginator $pager)
 {
     $collection = static::wrapCollection($pager->getCollection());
     return new LengthAwarePaginator($collection, $pager->total(), $pager->perPage(), $pager->currentPage());
 }
开发者ID:berle,项目名称:larakit,代码行数:5,代码来源:Presenter.php

示例9: handlePagination

 /**
  * @param LengthAwarePaginator $pagination
  * @param null|Fractal\TransformerAbstract $transformer
  * @return array
  */
 private function handlePagination(LengthAwarePaginator $pagination, $transformer = null)
 {
     $transformer = $transformer ?: TransformerFactory::create(class_basename($pagination->getCollection()->first()));
     $resource = new Fractal\Resource\Collection($pagination->getCollection(), $transformer);
     $resource->setPaginator(new Fractal\Pagination\IlluminatePaginatorAdapter($pagination));
     return $this->handleResource($resource);
 }
开发者ID:chico-rei,项目名称:restify,代码行数:12,代码来源:ResponseFactory.php


注:本文中的Illuminate\Pagination\LengthAwarePaginator::getCollection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。