@param AbstractPaginator|LengthAwarePaginator|Paginator $paginator

@return \League\Fractal\Resource\Collection
181828
protected function transformPaginator($paginator)
    {
        $collection = $paginator->getCollection();
        $resource = new Collection($collection, $this->getTransformer(), $this->resourceKeyCollection);
        $resource->setPaginator(new IlluminatePaginatorAdapter($paginator));

        return $resource;
    }
1012504
public function getPages(Paginator $paginator, $pageRange = null)
    {
        if ($pageRange === null) {
            $pageRange = $paginator->getPageRange();
        }

        $pageNumber = $paginator->getCurrentPageNumber();
        $pageCount  = count($paginator);

        if ($pageRange > $pageCount) {
            $pageRange = $pageCount;
        }

        $delta = ceil($pageRange / 2);

        if ($pageNumber - $delta > $pageCount - $pageRange) {
            $lowerBound = $pageCount - $pageRange + 1;
            $upperBound = $pageCount;
        } else {
            if ($pageNumber - $delta < 0) {
                $delta = $pageNumber;
            }

            $offset     = $pageNumber - $delta;
            $lowerBound = $offset + 1;
            $upperBound = $offset + $pageRange;
        }

        return $paginator->getPagesInRange($lowerBound, $upperBound);
    }
1266054
protected function handleInvalidPage(LengthAwarePaginator $paginator)
    {
        if ($paginator->lastPage() && $paginator->currentPage() > $paginator->lastPage()) {
            $lastPageUrl = Request::fullUrlWithQuery([
                $paginator->getPageName() => $paginator->lastPage(),
            ]);

            Pjax::respond(redirect($lastPageUrl));
        }
    }
1119874
private function generatedPresent(LengthAwarePaginator $paginator): Collection
    {
        return collect($paginator->items())
            ->map(function ($item) {
                return (object) [
                    'title'    => $item->searchTitle(),
                    'subTitle' => $item->searchSubTitle(),
                    'url'      => $item->searchUrl(),
                    'avatar'   => $item->searchAvatar(),
                ];
            });
    }
1121494
protected function initBuildUrlClosure(LengthAwarePaginator $paginator, $url, array $parameters = [])
    {
        if ($this->buildUrlClosure === null) {
            $pageSize   = $paginator->perPage();
            $urlLength  = strlen($url);
            $separator  = $urlLength > 0 && substr($url, -1) === '/' ? '?' : '/?';

            $this->buildUrlClosure = function ($pageNumber) use ($url, $parameters, $separator, $pageSize) {
                $paramsWithPaging = array_merge($parameters, [
                    QueryParametersParserInterface::PARAM_PAGE => [
                        self::PARAM_PAGING_SIZE   => $pageSize,
                        self::PARAM_PAGING_NUMBER => $pageNumber,
                    ]
                ]);
                $fullUrl = $url . $separator . http_build_query($paramsWithPaging);

                return $fullUrl;
            };
        }
    }
982224
private function _setPagination(array $pagination) {
		foreach ($this->_paginationEnvelopeKeys as $key => $name) {
			$this->_pagination[$key] = isset($pagination[$name])
				? $pagination[$name]
				: null;
		}

		return $this;
	}
242838
public function serializeCollection(Collection $collection, Request $request, $paginator)
    {
        $transformer = $this->getFractalTransformer($collection->get(0), $request);

        $resource = new Fractal\Resource\Collection($collection, $transformer, $this->getResourceName());
        $resource->setPaginator(new IlluminatePaginatorAdapter($paginator));

        return $this->getFractalManager($request)->createData($resource)->toArray();
    }
154752
protected function pager()
    {
        if ($this->pager === null) {
            $this->pager = $this->createPagination();
        }

        return $this->pager;
    }
1282060
def get_paginator(
        self,
        dataset,
        per_page,
        orphans=0,
        allow_empty_first_page=True,
        **kwargs
    ):
        """"""
        return IndefinitePaginator(
            dataset,
            per_page,
            orphans=orphans,
            allow_empty_first_page=allow_empty_first_page,
            **kwargs
        )
408251
public function getRightPoint(LengthAwarePaginator $paginator)
    {
        $side = $paginator->onEachSide;
        $current = $paginator->currentPage();
        $last = $paginator->lastPage();

        if (! empty($side)) {
            $offset = $current <= $side ? $side - $current + 1 : 0;
            $right = $current + $side + $offset;
        }

        return ! isset($right) || $right > $last ? $last : $right;
    }
676341
protected function isPageInRange(LengthAwarePaginator $paginator)
    {
        return $paginator->currentPage() <= ceil($paginator->lastItem() / $paginator->perPage());
    }
563015
public function paginateES(int $size = 20, string $sortBy = "", string $sortType = "ASC", int $page = null) : LengthAwarePaginator
    {
        if(!$page) {
            $page = (Input::get("page") ? Input::get("page") : 1);
        }

        $from = (($page * $size) - $size);

        $data = $this->getESItems($size, $from, $sortBy, $sortType);
        return new LengthAwarePaginator($data['items'], $data['elasticData']['hits']['total'], $size, $page);
    }
781649
public function pager(ODataQueryPager $pager = NULL) {
        if (isset($pager)) {
            $this->setPager($pager);
            return $this;
        }
        return $this->getPager();
    }
455769
public function paginate(AbstractQuery $query, $perPage, $pageName = 'page', $fetchJoinCollection = true)
    {
        return PaginatorAdapter::fromRequest(
            $query,
            $perPage,
            $pageName,
            $fetchJoinCollection
        )->make();
    }
1042038
public function paginator(PaginatorInterface $paginator)
    {
        $currentPage = (int)$paginator->getCurrentPage();
        $lastPage = (int)$paginator->getLastPage();

        $pagination = [
            'total' => (int)$paginator->getTotal(),
            'count' => (int)$paginator->getCount(),
            'per_page' => (int)$paginator->getPerPage(),
            'current_page' => $currentPage,
            'total_pages' => $lastPage,
        ];

        $pagination['links'] = [];

        $pagination['links']['self'] = $paginator->getUrl($currentPage);
        $pagination['links']['first'] = $paginator->getUrl(1);

        if ($currentPage > 1) {
            $pagination['links']['prev'] = $paginator->getUrl($currentPage - 1);
        }

        if ($currentPage < $lastPage) {
            $pagination['links']['next'] = $paginator->getUrl($currentPage + 1);
        }

        $pagination['links']['last'] = $paginator->getUrl($lastPage);

        return ['pagination' => $pagination];
    }
773811
protected function paginator(Paginator $paginator, Request $request)
    {
        foreach ($request->query as $key => $value) {
            if ($key != 'page') {
                $paginator->appends($key, $value);
            }
        }

        $pagination = [
            'pagination' => [
                'total'        => (int) $paginator->total(),
                'count'        => count($paginator->items()),
                'per_page'     => (int) $paginator->perPage(),
                'current_page' => (int) $paginator->currentPage(),
                'total_pages'  => (int) $paginator->lastPage(),
                'links'        => [
                    'next_page'     => $paginator->nextPageUrl(),
                    'previous_page' => $paginator->previousPageUrl(),
                ],
            ],
        ];

        $items = $paginator->getCollection();

        return $this->setMetaData($pagination)->setData(AutoPresenter::decorate($items->values()))->respond();
    }
987333
public function getPaginationControl(PaginatorInterface $paginator) {
		$currentPage = $paginator->getCurrentPage();
		
		$data = [
			PaginatorInterface::CONTROL_CURRENT => $currentPage,
			PaginatorInterface::CONTROL_RANGE   => [$currentPage]
		];
		
		if ($currentPage > 2) {
			$data[PaginatorInterface::CONTROL_FIRST] = 1;
		}
		
		if ($currentPage > 1) {
			$data[PaginatorInterface::CONTROL_PREVIOUS] = $currentPage - 1;
		}
		
		if ($paginator->count() >= $paginator->getItemsNumberPerPage()) {
			$data[PaginatorInterface::CONTROL_NEXT] = $currentPage + 1;
		}
		
		return $data;
	}