request = $request; } /** * @param $model * @param RepositoryInterface $repository * * @return mixed */ public function apply($model, RepositoryInterface $repository) { if ($this->request->filled('type_id')) { $type_id = $this->request->get('type_id'); $model = $model->where('type_id', '=', $type_id); } if ($this->request->filled('title')) { $title = $this->request->get('title'); $model = $model->where('title', 'like', "%{$title}%"); } if ($this->request->filled('subtitle')) { $subtitle = $this->request->get('subtitle'); $model = $model->where('subtitle', 'like', "%{$subtitle}%"); } if ($this->request->filled('content')) { $content = $this->request->get('content'); $model = $model->where('content', 'like', "%{$content}%"); } $model = $model->orderBy('created_at', 'desc'); return $model; } }