Retrieve all collections for a given page

@param  integer $page     Page from which the collections need to be retrieved
@param  integer $per_page Number of elements on a page
@return ArrayObject of Collections
546625
public static function all($page = 1, $per_page = 10)
    {
        $collections = self::get(
            "/collections",
            ['query' => ['page' => $page, 'per_page' => $per_page]]
        );

        $collectionsArray = self::getArray($collections->getBody(), get_called_class());

        return new ArrayObject($collectionsArray, $collections->getHeaders());
    }
86768
public function paginate($per_page = 5, $page = null, $page_name = 'imap_page'){
        $this->page = $page > $this->page ? $page : $this->page;
        $this->limit = $per_page;

        return $this->get()->paginate($per_page, $this->page, $page_name);
    }
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);
    }
1106933
public function paginate($page = 1, $perPage = 15)
    {
        $cacheKey = "$page|$perPage";

        if (isset($this->_paginationCache[$cacheKey])) {
            return $this->_paginationCache[$cacheKey];
        }

        $this->parseInputOnce();

        $this->_paginationCache[$cacheKey] = $this->createPaginator(
            $this->filters,
            $this->sorting(),
            $this->queryKeys(),
            $page,
            $perPage
        );

        return $this->_paginationCache[$cacheKey];

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

        return $this;
    }
845003
protected function performSearch(Builder $builder, $perPage = 0, $page = 1)
    {
        // We have to preserve the model in order to allow for
        // correct behavior of mapIds() method which currently
        // does not receive a model instance
        $this->preserveModel($builder->model);

        $indexColumn = $this->getIndexColumn($builder->model);

        // Build the SQL query
        $query = $this->database
            ->table($builder->index ?: $builder->model->searchableAs())
            ->select($builder->model->getKeyName())
            ->selectRaw("{$this->rankingExpression($builder->model, $indexColumn)} AS rank")
            ->selectRaw('COUNT(*) OVER () AS total_count')
            ->whereRaw("$indexColumn @@ \"tsquery\"");

        // Apply where clauses that were set on the builder instance if any
        foreach ($builder->wheres as $key => $value) {
            $query->where($key, $value);
        }

        // If parsed documents are being stored in the model's table
        if (! $this->isExternalIndex($builder->model)) {
            // and the model uses soft deletes we need to exclude trashed rows
            if ($this->usesSoftDeletes($builder->model)) {
                $query->whereNull($builder->model->getDeletedAtColumn());
            }
        }

        // Apply order by clauses that were set on the builder instance if any
        foreach ($builder->orders as $order) {
            $query->orderBy($order['column'], $order['direction']);
        }

        // Apply default order by clauses (rank and id)
        if (empty($builder->orders)) {
            $query->orderBy('rank', 'desc')
                ->orderBy($builder->model->getKeyName());
        }

        if ($perPage > 0) {
            $query->skip(($page - 1) * $perPage)
                ->limit($perPage);
        }

        // The choices of parser, dictionaries and which types of tokens to index are determined
        // by the selected text search configuration which can be set globally in config/scout.php
        // file or individually for each model in searchableOptions()
        // See https://www.postgresql.org/docs/current/static/textsearch-controls.html
        $tsQuery = $builder->callback
            ? call_user_func($builder->callback, $builder, $this->searchConfig($builder->model), $query)
            : $this->defaultQueryMethod($builder->query, $this->searchConfig($builder->model));

        $query->crossJoin($this->database->raw($tsQuery->sql().' AS "tsquery"'));
        // Add TS bindings to the query
        $query->addBinding($tsQuery->bindings(), 'join');

        return $this->database
            ->select($query->toSql(), $query->getBindings());
    }
972724
public function getUsers($perPage = 15)
    {
        $directory = Google::make('directory');
        try {
            $r = $directory->users->listUsers([
                'domain' => config('users.google_apps_domain'),
                'maxResults' => $perPage
            ]);
        } catch (\Exception $e) {
            return json_decode($e->getMessage());
        }

        return $r->users;
    }
723554
public function simpleFetch($page = 1, $perPage = 15, array $columns = ['*'], array $filter = [], array $sort = [])
    {
        $this->instance = $this->repository->makeQuery();

        $this->multiFilterBy($filter)->multiSortBy($sort)->parseAliases($this->instance);

        return $this->instance->forPage($page, $perPage)->get($columns);
    }
383481
public function getPaginatedRoutes($sort = 'name', $perPage = null)
    {
        return $this->paginate(
            $this->getAllRoutes($sort), $perPage
        );
    }
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;
    }
40204
public function getAllPaginated($orderBy = array('id', 'asc'), $perPage = 25)
    {
        list($column, $order) = $orderBy;

        return $this->newQuery()->orderBy($column, $order)->paginate($perPage);
    }
138775
public function getSurveys($page = 1, $resultsPerPage = self::RESULTS_PER_PAGE, $sortBy = 'title', $sortOrder = 'DESC',
                               $title = null, \DateTime $startModifiedAt = null, \DateTime $endModifiedAt = null)
    {
        $params = array(
            'page' => $page,
            'per_page' => $resultsPerPage,
            'sort_by' => $sortBy,
            'sort_order' => $sortOrder,
        );

        $this->appendQueryParameter($params, 'title', $title);
        $this->appendQueryParameter($params, 'start_modified_at', $startModifiedAt, 'format', 'YYYY-MM-DDTHH:SS');
        $this->appendQueryParameter($params, 'end_modified_at', $endModifiedAt, 'format', 'YYYY-MM-DDTHH:SS');

        $response = $this->client->run('/surveys', HTTPMethod::GET, $params);

        if($response->isError()) {
            return $response;
        }

        return new ListResponse($response->getResponse(), $this->getClient(), Survey::class);
    }
742486
protected function chunk($translations, $page = 1, $perPage = 20)
    {
        if (!$count = count($translations)) {
            return [];
        }

        $pages = array_chunk($translations, $perPage, true);

        $min = 1;
        $max = ceil($count / $perPage);

        if ($page < $min || $page > $max) {
            $page = 1;
        }

        return $pages[$page - 1];
    }
712729
public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
    {
        $page = $page ?: Paginator::resolveCurrentPage($pageName);

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

        $results = ($total = $this->toBase()->getCountForPagination())
                                    ? $this->forPage($page, $perPage)->get($columns)
                                    : $this->model->newCollection();

        return $this->paginator($results, $total, $perPage, $page, [
            'path' => Paginator::resolveCurrentPath(),
            'pageName' => $pageName,
        ]);
    }
991656
public function paginateAll($perPage = 15, $pageName = 'page')
    {
        $query = $this->createQueryBuilder('o')->getQuery();

        return $this->paginate($query, $perPage, $pageName, false);
    }
455769
public function paginate(AbstractQuery $query, $perPage, $pageName = 'page', $fetchJoinCollection = true)
    {
        return PaginatorAdapter::fromRequest(
            $query,
            $perPage,
            $pageName,
            $fetchJoinCollection
        )->make();
    }
280423
private function processPaginatedResults($pages, $perPage = 50, $currentPage = 0)
    {
        // Make sure we have at least one page of results
        if (count($pages) > 0) {
            $objects = [];

            // Go through each page
            foreach ($pages as $results) {
                // Get the entries for each page
                $entries = $this->connection->getEntries($results);

                /*
                 * If we've retrieved entries, we'll go through
                 * each and construct the entry attributes, and
                 * put them all inside the objects array
                 */
                if (is_array($entries) && array_key_exists('count', $entries)) {
                    for ($i = 0; $i < $entries['count']; $i++) {
                        $entry = $this->newLdapEntry($entries[$i], $this->connection);

                        $objects[] = $entry->getAttributes();
                    }
                }
            }

            /*
             * If we're sorting, we'll process all of
             * our results so it's sorted correctly
             */
            if (!empty($this->sortByField)) {
                $objects = $this->processSortBy($objects);
            }

            // Return a new Paginator instance
            return $this->newPaginator($objects, $perPage, $currentPage, count($pages));
        }

        // Looks like we don't have any results, return false
        return false;
    }