當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。