本文整理汇总了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;
}
示例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();
}
示例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);
}
示例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());
}
示例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);
}
示例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;
}
示例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)]];
}