本文整理汇总了PHP中Illuminate\Database\Eloquent\Builder::limit方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::limit方法的具体用法?PHP Builder::limit怎么用?PHP Builder::limit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Builder
的用法示例。
在下文中一共展示了Builder::limit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: applyLimit
/**
* @param $value
* @return $this
*/
public function applyLimit($value)
{
/**
* Save to conditons.
*/
$this->addCondition('limit', $value);
$this->model = $this->model->limit($value);
return $this;
}
示例2: pagination
/**
* Возвращает коллекцию в виде пагинации
*
* @param int $page
* @param int $limit
*/
public function pagination($page, $limit = 10)
{
/**
* @var \Illuminate\Support\Collection $data
*/
$countTotal = $this->_query->count();
$this->_query->skip($limit * $page - $limit);
$this->_query->limit($limit);
$data = collect();
foreach ($this->_query->get() as $key => $instance) {
$_listRow = [];
foreach ($this->columns->getColumns() as $column) {
$_listRow[$column->getKey()] = $column->getValues($instance);
}
$buttons = $this->filterAction($instance);
if (count($buttons)) {
$_listRow = array_merge($_listRow, [GridColumn::ACTION_NAME => implode('', $buttons)]);
}
$data->offsetSet($key, $_listRow);
}
return new \Illuminate\Pagination\LengthAwarePaginator($data, $countTotal, $limit, $page, ['path' => \Illuminate\Pagination\Paginator::resolveCurrentPath(), 'pageName' => 'page']);
}
示例3: scopeRecentlyCreated
/**
* Recently created scope
*
* @param Builder $query
* @param int|null $limit
* @return Builder
*/
public function scopeRecentlyCreated(Builder $query, $limit = null)
{
$query->orderBy('created_at', 'desc');
if ($limit) {
$query->limit($limit);
}
return $query;
}
示例4: limitCriterion
public function limitCriterion(QueryBuilder $query, $limit)
{
return $query->limit($limit);
}
示例5: apply
/**
* @param \Illuminate\Database\Eloquent\Builder $model
* @param RepositoryInterface $repository
* @return mixed
*/
public function apply($model, Repository $repository)
{
return $model->limit(15);
}
示例6: process
/**
* @param Builder|EloquentBuilder $src
* @param OperationInterface|PaginateOperation $operation
* @return mixed
*/
public function process($src, OperationInterface $operation)
{
$src->limit($operation->getPageSize())->offset($this->getOffset($operation));
return $src;
}
示例7: limit
/**
* Limit the number of rows returned
*
* @param integer $limit
* @return $this
*/
public function limit($limit)
{
$this->builder = $this->builder->limit($limit);
return $this;
}
示例8: limit
public function limit($limit)
{
$this->original->limit($limit);
return $this;
}