Get the number of models to return per page.
public getPerPage ( ) : integer | ||
Résultat | integer |
/** * Paginate the given query into a simple paginator. * * @param int $perPage * @param array $columns * @return \Illuminate\Contracts\Pagination\Paginator */ public function simplePaginate($perPage = null, $columns = ['*']) { $page = Paginator::resolveCurrentPage(); $perPage = $perPage ?: $this->model->getPerPage(); $this->skip(($page - 1) * $perPage)->take($perPage + 1); return new Paginator($this->get($columns)->all(), $perPage, $page, ['path' => Paginator::resolveCurrentPath()]); }
/** * Get a paginator only supporting simple next and previous links. * * This is more efficient on larger data-sets, etc. * * @param int $perPage * @param array $columns * @return \Illuminate\Pagination\Paginator */ public function simplePaginate($perPage = null, $columns = array('*')) { $paginator = $this->query->getConnection()->getPaginator(); $page = $paginator->getCurrentPage(); $perPage = $perPage ?: $this->model->getPerPage(); $this->query->skip(($page - 1) * $perPage)->take($perPage + 1); return $paginator->make($this->get($columns)->all(), $perPage); }
/** * Paginate the returned set of models. * * @param int $perPage * @param array $columns * @param string $pageName * @param int|null $page * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator * * @throws \InvalidArgumentException */ public function paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null) { $query = $this->model->toBase(); $total = $query->getCountForPagination(); $model = $this->model->forPage($page = $page ?: Paginator::resolveCurrentPage($pageName), $perPage = $perPage ?: $this->model->getPerPage()); $results = new LengthAwarePaginator($this->hookPaginate($model->get($columns)), $total, $perPage, $page, ['path' => Paginator::resolveCurrentPath(), 'pageName' => $pageName]); $this->reset(); return $results; }
/** * Get a paginator for the "select" statement. * * @param int $perPage * @param array $columns * @return \Illuminate\Pagination\Paginator */ 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); } }
/** * Get per page items count. * * @return int */ public function getPerPage() { return $this->model->getPerPage(); }