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('pid')) { $model = $model->where('pid', '=', $this->request->get('pid')); } if ($this->request->filled('status')) { $model = $model->where('status', '=', $this->request->get('status')); } if (!$this->request->filled('orderBy')) { $model = $model->orderByDesc('id'); } return $model; } }