本文整理汇总了PHP中Illuminate\Database\Eloquent\Builder::skip方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::skip方法的具体用法?PHP Builder::skip怎么用?PHP Builder::skip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Builder
的用法示例。
在下文中一共展示了Builder::skip方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filter
private function filter(\Illuminate\Database\Eloquent\Builder $_db)
{
$_db->take($this->limit);
if (Request::get('offset')) {
$_db->skip(Request::get('offset'));
}
return $_db;
}
示例2: filter
private function filter(\Illuminate\Database\Eloquent\Builder $_db)
{
$_db->take($this->limit);
if (Request::get('offset')) {
$_db->skip(Request::get('offset'));
}
if (Request::get('q')) {
$_db->where('description', 'like', Request::get('q') . '%');
}
return $_db;
}
示例3: getItems
public function getItems($limit, $offset)
{
$builder = $this->query->getQuery();
if ($builder->groups || $builder->unions) {
$row = DB::selectOne("SELECT COUNT(*) qty FROM (" . $this->query->toSql() . ") sub", $this->query->getBindings());
$total = (int) $row->qty;
} else {
$total = $this->query->count();
}
$pageOfItems = $this->query->skip($offset)->take($limit)->get();
return [$pageOfItems, $total];
}
示例4: setClauses
/**
* Set clauses on the query builder
*
* @return $this
*/
protected function setClauses()
{
foreach ($this->wheres as $where) {
$this->query->where($where['column'], $where['operator'], $where['value']);
}
foreach ($this->whereIns as $whereIn) {
$this->query->whereIn($whereIn['column'], $whereIn['values']);
}
foreach ($this->orderBys as $orders) {
$this->query->orderBy($orders['column'], $orders['direction']);
}
if (isset($this->take) and !is_null($this->take)) {
$this->query->take($this->take);
}
if (isset($this->skip) and !is_null($this->skip)) {
$this->query->skip($this->skip);
}
if (isset($this->paginate) and !is_null($this->paginate)) {
$this->query->paginate($this->paginate);
}
return $this;
}
示例5: 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']);
}
示例6: paging
/**
* Datatable paging
*
* @return null
*/
protected function paging()
{
if (!is_null($this->input['start']) && !is_null($this->input['length']) && $this->input['length'] != -1) {
$this->query->skip($this->input['start'])->take((int) $this->input['length'] > 0 ? $this->input['length'] : 10);
}
}
示例7: getItems
public function getItems($limit, $offset)
{
$total = $this->query->getQuery()->getCountForPagination();
$pageOfItems = $this->query->skip($offset)->take($limit)->get();
return [$pageOfItems, $total];
}
示例8: scopeOffset
/**
* Offset the results
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param int $offset
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeOffset(Builder $query, $offset)
{
return $query->skip($offset);
}
示例9: skip
/**
* Skip a certain amount of rows
*
* @param integer $skip
* @return $this
*/
public function skip($skip)
{
$this->builder = $this->builder->skip($skip);
return $this;
}
示例10: buildPagination
/**
* @param PaginationParameters $paginationParameters
* @param Builder $query
* @return Builder
*/
public function buildPagination(PaginationParameters $paginationParameters, Builder $query)
{
$page = $paginationParameters->getPage();
$limit = $paginationParameters->getLimit();
return $query->skip($limit * ($page - 1))->take($limit);
}