Paginate query results.

@param  int|string $page
@param  int|string $perPage

@return self
485098
public function paginate($page, $perPage = null)
    {
        $this->queryDefaults['paged'] = $page;
        $this->queryDefaults['posts_per_page'] = $perPage ?: get_option('posts_per_page');

        return $this;
    }
415300
public function paginate($perPage = 15, $page = null, $options = [], $setPath = null)
    {
        $page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
        $items = ($this instanceof Collection || $this instanceof PostCollection) ? $this : Collection::make($this);
        $paginator = new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options);

        // Set Path
        if(is_null($setPath)) {
            $paginator->setPath(\Request::url());
        }else{
            $paginator->setPath($setPath);
        }
        return $paginator;
    }
86539
public function paginate($per_page = 15, $page = null, $page_name = 'page') {
        $page = $page ?: Paginator::resolveCurrentPage($page_name);

        $results = ($total = $this->count()) ? $this->forPage($page, $per_page) : $this->all();

        return $this->paginator($results, $total, $per_page, $page, [
            'path'      => Paginator::resolveCurrentPath(),
            'pageName'  => $page_name,
        ]);
    }
126129
public function paginate(Builder $builder, $perPage, $page)
    {
        $results = $this->performSearch($builder);

        if ($builder->limit) {
            $results['hits'] = $builder->limit;
        }

        $filtered = $this->discardIdsFromResultSetByConstraints($builder, $results['ids']);

        $results['hits'] = $filtered->count();

        $chunks = array_chunk($filtered->toArray(), $perPage);

        if (empty($chunks)) {
            return $results;
        }

        if (array_key_exists($page - 1, $chunks)) {
            $results['ids'] = $chunks[$page - 1];
        } else {
            $results['ids'] = end($chunks);
        }

        return $results;
    }
32176
public function simplePaginate($perPage = null, $columns = ['*'], $pageName = 'page')
	{
		$this->query->addSelect($this->getSelectColumns($columns));

		return $this->query->simplePaginate($perPage, $columns, $pageName);
	}
657133
protected function paginate($items, $perPage = 15)
    {
        $currentPage = LengthAwarePaginator::resolveCurrentPage();

        $currentPageItems = collect($items)->slice(($currentPage - 1) * $perPage, $perPage);

        return new LengthAwarePaginator($currentPageItems, count($items), $perPage);
    }
1072895
public function forPage($page, $perPage = 15)
	{
		if( $page < 1 )
		{
			$page = 1;
		}
		return $this->limit($perPage, ($page - 1) * $perPage);
	}
1372396
public function simplePaginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
    {
        $page = $page ?: Paginator::resolveCurrentPage($pageName);

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

        // Next we will set the limit and offset for this query so that when we get the
        // results we get the proper section of results. Then, we'll create the full
        // paginator instances for these results with the given page and per page.
        $this->skip(($page - 1) * $perPage)->take($perPage + 1);

        return $this->simplePaginator($this->get($columns), $perPage, $page, [
            'path' => Paginator::resolveCurrentPath(),
            'pageName' => $pageName,
        ]);
    }
1258093
public function paginate($page, $per_page = 50) 
    {
        $this->_builder->limit  = $per_page;
        $this->_builder->offset = ($page - 1) * $per_page;
        $this->page             = $page;
        $this->per_page         = $per_page;

        if (Driver::$pagination_subquery) {
            $this->_builder->limit   = $this->_builder->offset + $per_page;
            $this->_builder->offset  = $this->_builder->offset + 1;
        }
        return $this;
    }
1025533
public function paginate($perPage = 15, $columns = ['*'], $pageName = 'page', $page = null)
    {
        $result = $this->getBuilder()->paginate($perPage, $columns, $pageName, $page);

        // Reset query builder
        $this->resetBuilder();

        return $result;
    }
1252551
public function perPage($per_page)
    {
        $this->limit = $per_page;
        $this->offset = ($this->page - 1) * $per_page;
        return $this;
    }
115105
public function paginate(Builder $builder, $perPage, $page)
    {
        return $this->performSearch($builder, [
            'numericFilters' => $this->filters($builder),
            'hitsPerPage' => $perPage,
            'page' => $page - 1,
        ]);
    }
1116175
public function paginate(Builder $builder, $perPage, $page)
    {
        $results = $this->performSearch($builder);

        if ($builder->limit) {
            $results['hits'] = $builder->limit;
        }

        $chunks = array_chunk($results['ids'], $perPage);

        if (! empty($chunks)) {
            if (array_key_exists($page - 1, $chunks)) {
                $results['ids'] = $chunks[$page - 1];
            } else {
                $results['ids'] = end($chunks);
            }
        }

        return $results;
    }
346635
final public function page($pageNumber, $recordsPerPage = null)
    {
        $recordsPerPage = $recordsPerPage ?? $this->recordsPerPage;

        $this->getQuery()->limit(((int)$pageNumber) * $recordsPerPage, $recordsPerPage);
        $this->pagedQuery = true;

        return $this;
    }
1338667
public function paginate($perPage = 15, $columns = ['*'], $sort = '', $order = 'asc')
    {
        $m = $this->model;

        if ($sort) {
            $m->orderBy($sort, $order);
        } else {
            if ($this->defaultOrderColumn) {
                $m->orderBy($this->defaultOrderColumn, $order);
            }
        }
        return $m->paginate($perPage, $columns);
    }
1008383
public function page ($page, $per_page = null)
	{
		$model = $this->model;

		if($per_page === null) { $per_page = $model::$per_page; }

		$this->offset($page * $per_page)->limit($per_page);

		return $this;
	}
1358525
public function setDefaultPerPage($perPage)
    {
        $perPage = (int) $perPage;
        $this->defaultPerPage = $perPage;

        if (!in_array($perPage, $this->perPageList)) {
            $this->perPageList[] = $perPage;
            sort($this->perPageList);
        }

        return $this;
    }