"Paginate" the collection by slicing it into a smaller collection.

        :param page: The current page
        :type page: int

        :param per_page: Number of items by slice
        :type per_page: int

        :rtype: Collection
491260
def for_page(self, page, per_page):
        
        start = (page - 1) * per_page

        return self[start:start + per_page]
1325919
public function paginate($page, $perPage = null)
    {
        $page = (int)$page;
        if ($page < 1) {
            $page = 1;
        }
        
        if ($perPage === null) {
            if (!$perPage = $this->select->getRawState('limit')) {
                throw new Exception\InvalidArgumentException(
                    "No per page passed and no limit is set"
                );
            }
        }
        
        $modelClass = $this->modelClass;
        $paginator  = new Paginator($this->select, $modelClass::adapter());
        $items      = $paginator->getItems(($page - 1) * $perPage, $perPage);
        $collection = $this->buildCollection($items->toArray());
        
        $collection->setPage($page);
        $collection->setPerPage($perPage);
        $collection->setPaginator($paginator);
        
        return $collection;
    }
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;
    }
773323
public function paginate($perPage = 10, array $columns = ['*'], $pageName = 'page', $page = null)
    {
        $this->applyCriteria();

        return $this->model->paginate($perPage, $columns, $pageName, $page);
    }
884411
public function paginate($perPage, $columns, $pageName, $page)
    {
        return $this->db->paginate($perPage, $columns, $pageName, $page);
    }
922331
public function paginate(int $perPage = 15, array $columns = ['*'], $pageName = 'page', int $page = 0): LengthAwarePaginator
    {
        $paginate = $this->queryRelate->getQuery()->paginate($perPage, $columns, $pageName, $page);

        $this->resetQueryRelate();

        return $paginate;
    }
753286
public function forPage($page, $perPage)
    {
        $offset = max(0, ($page - 1) * $perPage);

        return $this->slice($offset, $perPage);
    }
42590
def list(self, page=1, per_page=50):
        
        data = {"page": page,
                "per_page": per_page}
        return self.get(self.base_url, data=data)
851101
def paginate(self, page=1, perpage=10, category=None):
        """"""
        q = db.select(self.table).fields('title', 'slug', 'description', 'html', 'css', 'js',
                                         'category', 'status', 'comments', 'author', 'created', 'pid')
        if category:
            q.condition('category', category)
        results = (q.limit(perpage).offset((page - 1) * perpage)
                    .order_by('created', 'DESC').execute())
        return [self.load(data, self.model) for data in results]
471921
public function paginate($perPage = null, $columns = array('*'), $pageName = 'page', $page = null)
    {
        if (is_null($page)) {
            $page = Paginator::resolveCurrentPage($pageName);
        }

        $path = Paginator::resolveCurrentPath($pageName);

        if (is_null($perPage)) {
            $perPage = $this->model->getPerPage();
        }

        $total = $this->query->getPaginationCount();

        if ($total > 0) {
            $results = $this->forPage($page, $perPage)->get($columns);
        } else {
            $results = $this->model->newCollection();
        }

        return new Paginator($results, $total, $perPage, $page, compact('path', 'pageName'));
    }
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')
        );
    }
1007005
def limit options = {}
      # Remove this key if we come from limit_page method.
      page = options.delete :page
      query = options.dup
      collection = new_collection scoped_query( options = {
        :limit => options[:limit],
        :offset => options[:offset],
        :order => [options[:order]]
      }.merge( query ) )
      options.merge! :count => calculate_total_records( query ), :page => page
      collection.paginator = DataMapper::Paginator::Main.new options
      collection
    end
372377
public function paginate($items, $perPage = 10, $page = null, $options = [])
    {
        $page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
        $items = $items instanceof Collection ? $items : Collection::make($items);

        return new LengthAwarePaginator(
            $items->forPage($page, $perPage),
            $items->count(),
            $perPage,
            $page,
            $options
        );
    }
174387
public function paginate($perPage)
    {
        if (\filter_var($perPage, FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]) && ! \is_bool($perPage)) {
            $this->perPage = $perPage;
            $this->paginate = true;
        } elseif (\filter_var($perPage, FILTER_VALIDATE_BOOLEAN)) {
            $this->perPage = null;
            $this->paginate = $perPage;
        } else {
            $this->perPage = null;
            $this->paginate = false;
        }

        return $this;
    }
1140541
def pagination_for(list, options={})
      if list.respond_to? :total_pages
        options = {
          max_per_page: detail['pagination.max_per_page'] || 500,
          depaginate: true
        }.merge(options.symbolize_keys)
        depaginate = options.delete(:depaginate)                                     # supply depaginate: false to omit the 'show all' link
        depagination_limit = options.delete(:max_per_page)                           # supply max_per_page: false to include the 'show all' link no matter how large the collection
        html = will_paginate(list, will_paginate_options.merge(options))
        if depaginate && list.total_pages > 1 && (!depagination_limit.blank? || list.total_entries <= depagination_limit.to_i)
          html << content_tag(:div, link_to(t('show_all'), pp: 'all'), class: 'depaginate')
        elsif depaginate && list.total_entries > depagination_limit.to_i
          html = content_tag(:div, link_to("paginate", p: 1), class: 'pagination')
        end
        html
      end
    end
382648
def next_page(self):
        
        for link in self.links:
            if link.next:
                return self._load(link.next)
        raise PaginationError('No more entries.')
729327
public function paginate($page = 1, $itemsPerPage = 20)
    {
        $query = $this->createAndFilterQueryBuilder($this->getEntityAlias());
        $query->setFirstResult(($page - 1) * $itemsPerPage);
        $query->setMaxResults($itemsPerPage);
        return new Paginator($query);
    }