本文整理汇总了PHP中Illuminate\Database\Eloquent\Model::getPerPage方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::getPerPage方法的具体用法?PHP Model::getPerPage怎么用?PHP Model::getPerPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Model
的用法示例。
在下文中一共展示了Model::getPerPage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: simplePaginate
/**
* 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()]);
}
示例2: simplePaginate
/**
* 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);
}
示例3: paginate
/**
* 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;
}
示例4: paginate
/**
* 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);
}
}
示例5: getPerPage
/**
* Get per page items count.
*
* @return int
*/
public function getPerPage()
{
return $this->model->getPerPage();
}