Ejemplo n.º 1
0
 /**
  * @param $value
  * @return $this
  */
 public function applyLimit($value)
 {
     /**
      * Save to conditons.
      */
     $this->addCondition('limit', $value);
     $this->model = $this->model->limit($value);
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * Возвращает коллекцию в виде пагинации
  *
  * @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']);
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }
Ejemplo n.º 4
0
 public function limitCriterion(QueryBuilder $query, $limit)
 {
     return $query->limit($limit);
 }
Ejemplo n.º 5
0
 /**
  * @param \Illuminate\Database\Eloquent\Builder $model
  * @param RepositoryInterface $repository
  * @return mixed
  */
 public function apply($model, Repository $repository)
 {
     return $model->limit(15);
 }
 /**
  * @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;
 }
Ejemplo n.º 7
0
 /**
  * Limit the number of rows returned
  *
  * @param  integer $limit
  * @return $this
  */
 public function limit($limit)
 {
     $this->builder = $this->builder->limit($limit);
     return $this;
 }
Ejemplo n.º 8
0
 public function limit($limit)
 {
     $this->original->limit($limit);
     return $this;
 }