Adds pagination to the specified query builder.

@param \Doctrine\ORM\QueryBuilder $queryBuilder
@param integer $elementsPerPage
@param integer $page
@return \Doctrine\ORM\QueryBuilder
328343
protected function addPagination(QueryBuilder $queryBuilder, $elementsPerPage, $page = 1)
    {
        $elementsPerPage = (int)$elementsPerPage;
        $page = (int)$page;

        return $queryBuilder
            ->setMaxResults($elementsPerPage)
            ->setFirstResult($elementsPerPage * ($page - 1));
    }
37995
public function scopeSimplePaginateFilter($query, $perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
    {
        $perPage = $perPage ?: config('eloquentfilter.paginate_limit');
        $paginator = $query->simplePaginate($perPage, $columns, $pageName, $page);
        $paginator->appends($this->filtered);

        return $paginator;
    }
634753
public function getRootCategoriesPager($page = 1, $limit = 25, $criteria = [])
    {
        $page = 0 === (int) $page ? 1 : (int) $page;

        $queryBuilder = $this->getObjectManager()->createQueryBuilder()
            ->select('c')
            ->from($this->class, 'c')
            ->andWhere('c.parent IS NULL');

        $pager = new Pager($limit);
        $pager->setQuery(new ProxyQuery($queryBuilder));
        $pager->setPage($page);
        $pager->init();

        return $pager;
    }
607615
public function paginate($page, $perPage = null)
    {
        if ($page < 1) {
            $page = 1;
        }
        
        $paginator = new Paginator($this->select, $this->adapter());
        $items     = $paginator->getItems(($page - 1) * $perPage, $perPage);
        
        return $items->toArray();
    }
1030790
public function simplePagination($perPage = 15){
        $pegination = $this->pagination($perPage);

        $pegination->setMode(Paginator::MODE_SIMPLE);
        return $pegination;
    }
1225562
public function paginate($perPage = 20)
    {
        $page = request()->get('page', 1);
        $path = request()->url();

        return new LengthAwarePaginator(
            $this->forPage($page, $perPage),
            $this->count(),
            $perPage,
            $page,
            compact('path')
        );
    }
1041954
protected function paginate($keys, $page, $perPage)
    {
        return new LengthAwarePaginator(
            $this->chunk($keys, $page, $perPage),
            count($keys),
            20,
            $page,
            [
                'path' => Paginator::resolveCurrentPath(),
                'pageName' => 'page',
            ]
        );
    }
202930
public function paginate($perPage = null, $columns = array('*'))
	{
		$perPage = $perPage ?: $this->model->getPerPage();

		$paginator = $this->query->getConnection()->getPaginator();

		if (isset($this->query->groups))
		{
			return $this->groupedPaginate($paginator, $perPage, $columns);
		}
		else
		{
			return $this->ungroupedPaginate($paginator, $perPage, $columns);
		}
	}
162512
public function getPager($criteria, $page = 1)
    {
        $container = $this->getContainer();

        $paginator = $container->get('knp_paginator');

        $settings = $this->getSettings();

        $limit = $settings['articles_per_page'];

        $parameters = [];

        /** @var ArticlesRepository $repository */
        $repository = $this->getRepository();

        $qb = $repository->createQueryBuilder('p');

        $qb->select('p')->orderBy('p.publicationAt', 'DESC');

        if (!isset($criteria['enabled'])) {
            $criteria['enabled'] = true;
        }

        if (isset($criteria['enabled'])) {
            $currentTime = new \DateTime();

            $qb->andWhere('p.enabled = :enabled');
            $qb->andWhere(
                $qb->expr()->lt('p.publicationAt', ':datetime')
            );

            $parameters['datetime'] = $currentTime;
            $parameters['enabled'] = $criteria['enabled'];
        }

        $qb->setParameters($parameters);

        $pagination = $paginator->paginate(
            $qb,
            $page,
            $limit
        );

        return $pagination;
    }
595956
public function paginate($page = 1, $perPage = 15)
    {
        if ($this->paginatorCreator) {
            return call_user_func($this->paginatorCreator, $page, $perPage);
        }

        $all = iterator_to_array($this->getIterator());

        return array_slice($all, ($page-1)*$perPage, $perPage);
    }
351793
protected function convertToLaravelPaginator(DoctrinePaginator $doctrinePaginator, $perPage, $page)
    {
        $results     = iterator_to_array($doctrinePaginator);
        $path        = Paginator::resolveCurrentPath();

        return new LengthAwarePaginator(
            $results,
            $doctrinePaginator->count(),
            $perPage,
            $page,
            compact('path')
        );
    }
826357
protected function getPaginator4QueryBuilder(QueryBuilder $queryBuilder, int $count, int $page = 1): ?Paginator
    {
        if (!$queryBuilder) {
            return null;
        }

        $paginator = new Paginator(
            new DoctrineAdapter\SimpleQueryDoctrine($count, $queryBuilder->getQuery())
        );
        $paginator->setDefaultItemCountPerPage(25);
        $paginator->setCurrentPageNumber($page);

        return $paginator;
    }
58304
public function paginate($per_page = null, $columns = ['*'], $page_name = 'page', $page = null)
    {
        // Get the default per page when not set
        $per_page = $per_page ?: config('repositories.per_page', 15);

        // Get the per page max
        $per_page_max = config('repositories.max_per_page', 100);

        // Ensure the user can never make the per
        // page limit higher than the defined max.
        if ($per_page > $per_page_max) {
            $per_page = $per_page_max;
        }

        $this->newQuery();

        return $this->query->paginate($per_page, $columns, $page_name, $page);
    }
532630
public function forPage(int $page, int $perPage): CollectionInterface
    {
        $page--;
        $offset = $page * $perPage;

        return $this->slice($offset, $perPage);
    }
280250
public function paginate($perPage = null, $pageName = 'page', $page = null)
    {
        $engine = $this->engine();

        $page = $page ?: Paginator::resolveCurrentPage($pageName);

        $perPage = $perPage ?: $this->model->getPerPage();

        $results = $this->model->newCollection($engine->map(
            $this, $rawResults = $engine->paginate($this, $perPage, $page), $this->model
        )->all());

        $paginator = (new LengthAwarePaginator($results, $engine->getTotalCount($rawResults), $perPage, $page, [
            'path' => Paginator::resolveCurrentPath(),
            'pageName' => $pageName,
        ]));

        return $paginator->appends('query', $this->query);
    }
237450
protected function convertToLaravelPaginator(DoctrinePaginator $doctrinePaginator, $perPage, $pageName = 'page')
    {
        $results     = $this->getResults($doctrinePaginator);
        $currentPage = $this->getCurrentPage($pageName);
        $path        = Paginator::resolveCurrentPath();

        return new LengthAwarePaginator(
            $results,
            $doctrinePaginator->count(),
            $perPage,
            $currentPage,
            compact('path')
        );
    }
455769
public function paginate(AbstractQuery $query, $perPage, $pageName = 'page', $fetchJoinCollection = true)
    {
        return PaginatorAdapter::fromRequest(
            $query,
            $perPage,
            $pageName,
            $fetchJoinCollection
        )->make();
    }