request = $request; } /** * @param $model * @param RepositoryInterface $repository * * @return mixed */ public function apply($model, RepositoryInterface $repository) { // this is a Example if ($this->request->filled('name')) { $model = $model->where('name', 'like', '%' . $this->request->get('name') . '%'); } if ($this->request->filled('is_read')) { $model = $model->where('is_read', '=', $this->request->get('is_read')); } if ($this->request->filled('type')) { $model = $model->where('type', '=', $this->request->get('type')); } if ($this->request->filled('send_status')) { $model = $model->where('send_status', '=', $this->request->get('send_status')); } return $model; } }