/** * @param $value * @return $this */ public function applyOffset($value) { /** * Save to conditons. */ $this->addCondition('offset', $value); $this->model = $this->model->offset($value); return $this; }
public function build() { $request = $this->request; $needle = $request->needle(); if ($needle && $request->searchable) { $this->qb->where(function ($subQB) use($needle, $request) { foreach ($request->searchable as $column) { $subQB->orWhere($column, 'LIKE', "%{$needle}%"); } }); } $request->modifyQuery($this->qb); $this->qb->orderBy($request->orderBy(), $request->sortBy()); $count = $this->qb->count(); $this->qb->take($request->perPage()); $this->qb->offset($request->offset()); $paginator = new LengthAwarePaginator($request->items($this->qb), $count, $request->perPage(), $request->page()); $paginator->request = $request; $paginator->appends($request->query()); $this->paginator = $paginator; }
/** * @param $page * @param $itemsPerPage * * @return $this */ public function forPage($page, $itemsPerPage) { $this->specificationQuery->offset(($page - 1) * $itemsPerPage)->limit($itemsPerPage); return $this; }
/** * @param Builder $table * * @return Builder */ public function apply(Builder $table) { return $table->offset(($this->currentPage - 1) * $this->itemsPerPage)->limit($this->itemsPerPage); }