예제 #1
0
 /**
  * @param $value
  * @return $this
  */
 public function applyOffset($value)
 {
     /**
      * Save to conditons.
      */
     $this->addCondition('offset', $value);
     $this->model = $this->model->offset($value);
     return $this;
 }
예제 #2
0
 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;
 }
예제 #3
0
 /**
  * @param $page
  * @param $itemsPerPage
  *
  * @return $this
  */
 public function forPage($page, $itemsPerPage)
 {
     $this->specificationQuery->offset(($page - 1) * $itemsPerPage)->limit($itemsPerPage);
     return $this;
 }
예제 #4
0
 /**
  * @param Builder $table
  *
  * @return Builder
  */
 public function apply(Builder $table)
 {
     return $table->offset(($this->currentPage - 1) * $this->itemsPerPage)->limit($this->itemsPerPage);
 }