本文整理汇总了PHP中Illuminate\Database\Eloquent\Builder::paginate方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::paginate方法的具体用法?PHP Builder::paginate怎么用?PHP Builder::paginate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Builder
的用法示例。
在下文中一共展示了Builder::paginate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: paginate
/**
* Get paginated list
*
* @param int $perPage
* @param array $columns
* @return mixed
*/
public function paginate($perPage = 15, $columns = ['*'])
{
$this->newQuery()->eagerLoad()->setClauses()->setScopes();
$models = $this->query->paginate($perPage, $columns);
$this->unsetClauses();
return $models;
}
示例2: paginate
/**
* Retrieve all data of repository, paginated
*
* @param null $limit
* @param array $columns
* @return mixed
*/
public function paginate($limit = null, $columns = ['*'])
{
return $this->wrap(function ($limit = null, $columns = ['*']) {
$limit = is_null($limit) ? $this->perPage : $limit;
return $this->model->paginate($limit, $columns);
}, new Action(__METHOD__, func_get_args(), Action::READ));
}
示例3: scopeGetConnection
/**
* Paginate connection w/ query args.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array $args
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeGetConnection($query, array $args)
{
$first = isset($args['first']) ? $args['first'] : 15;
$after = $this->decodeCursor($args);
$page = isset($args['page']) ? $args['page'] : 1;
$currentPage = $first && $after ? floor(($first + $after) / $first) : $page;
return $query->paginate($first, ['*'], 'page', $currentPage);
}
示例4: customPaginate
/**
* Custom Paginate current results, for queries that cannot be paginated using paginate().
*
* @param int $total
* @param int $per_page
*
* @return LengthAwarePaginator
*/
public function customPaginate($total, $per_page = 20)
{
$this->per_page = $per_page;
$this->buildQuery();
$current_page = Paginator::resolveCurrentPage() ? Paginator::resolveCurrentPage() : 1;
$data = $this->query->paginate($per_page)->items();
$pagination = new LengthAwarePaginator($data, $total, $per_page, $current_page, ['path' => Paginator::resolveCurrentPath()]);
return $pagination;
}
示例5: paginate
/**
* Paginate the results of this query
*
* @param int
* @param int
* @return $this
*/
public function paginate($perPage, $page)
{
if ($perPage > 0) {
Paginator::currentPageResolver(function () use($page) {
return $page;
});
$this->paginator = $this->query->paginate($perPage);
} else {
$this->collection = $this->query->get();
}
return $this;
}
示例6: paginate
public function paginate($perPage = null, $columns = array("*"), $itemProcessor = null)
{
if ($this->disableEloficient) {
return parent::paginate($perPage, $columns = array("*"));
}
$perPage = $perPage ?: ($_GET["perpage"] ?: $this->model->getPerPage());
$paginator = $this->query->getConnection()->getPaginator();
$this->prepareForPagination = true;
$this->query->forPage($paginator->getCurrentPage(), $perPage);
$collection = $this->get($columns);
$totalRows = $this->getPaginationTotalRows();
if ($itemProcessor instanceof Closure) {
$collection = call_user_func($itemProcessor, $collection);
}
return $paginator->make($collection->all(), $totalRows, $perPage);
}
示例7: pagination
/**
* Pagination for query
*
* @param $query
*
* @return LengthAwarePaginator
*/
protected function pagination(Builder $query, $page = null)
{
$action = $this->action;
$page = is_null($page) ? Input::get('page') : $page;
$max_per_page = $this->getConfig($action)['max_per_page'];
return $query->paginate($max_per_page, ['*'], 'page', $page);
}
示例8: paginate
/**
* Get the paginated entries.
*
* @param array $columns
* @return Paginator
*/
public function paginate($perPage = 15, array $columns = ['*'])
{
return (new Decorator())->decorate($this->query->paginate($perPage, $columns));
}
示例9: paginate
/**
* 翻页
* @param int $perPage
* @param string $pageName
* @param int|null $page
* @return static
*/
public function paginate(int $perPage, string $pageName = 'page', int $page = null)
{
$this->original->paginate($perPage, ['*'], $pageName, $page);
return $this;
}
示例10: paginate
/**
* @param Builder $builder
* @return PageInterface
*/
protected function paginate(Builder $builder)
{
$size = $this->getPerPage();
$page = new Page($this->service);
$data = $this->simplePagination ? $builder->simplePaginate($size) : $builder->paginate($size);
$page->setData($data);
return $page;
}
示例11: paginate
/**
* Retrieve all data of repository, paginated
*
* @param null $limit
* @param array $columns
*
* @return \Illuminate\Pagination\Paginator
*/
public function paginate($limit = null, $columns = ['*'])
{
$this->newQuery();
return $this->query->paginate($limit, $columns);
}
示例12: findAllWithPagination
/**
* @param null $pagination
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function findAllWithPagination($pagination = null)
{
$pagination = $pagination ?: self::PAGINATION;
return $this->instance->paginate($pagination);
}
示例13: getPaginatedResults
private static function getPaginatedResults(Builder $query)
{
return $query->paginate(config('settings.products.results'));
}
示例14: paginateAll
/**
* Paginate all posts.
*
* @param int $postsPerPage
*
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
public function paginateAll($postsPerPage)
{
return $this->model->paginate($postsPerPage);
}
示例15: paginate
/**
* Paginate a result set and reset the query.
*
* @param {int} $limit
*
* @return \Illuminate\Pagination\Paginator
*/
public function paginate($limit)
{
$ret = $this->query->paginate($limit);
$this->reset();
return $ret;
}