request = $request; } /** * @param $model * @param RepositoryInterface $repository * * @return mixed */ public function apply($model, RepositoryInterface $repository) { if ($this->request->filled('name')) { $model = $model->where('name', 'like', '%' . $this->request->get('name') . '%'); } if ($this->request->filled('account')) { $model = $model->where('account', 'like', '%' . $this->request->get('account')); } if ($this->request->filled('mobile')) { $model = $model->where('mobile', 'like', '%' . $this->request->get('mobile')); } if ($this->request->filled('grade_id')) { $grade_id = $this->request->get('grade_id'); if($grade_id){ $model = $model->where('grade_id', '=', $this->request->get('grade_id')); } } if ($this->request->filled('status')) { $model = $model->where('status', '=', $this->request->get('status')); } if (!$this->request->filled('orderBy')) { $model = $model->orderByDesc('id'); } return $model; } }