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', '=', $this->request->get('name')); //} if ($this->request->filled('url')) { $model = $model->where('url', 'like', $this->request->get('url') . '%'); } if ($this->request->filled('method')) { $model = $model->where('method', '=', $this->request->get('method')); } if ($this->request->filled('username')) { $model = $model->where('username', 'like', $this->request->get('username') . '%'); } if ($this->request->filled('start_date')) { $model = $model->whereDate('created_at', '>=', $this->request->get('start_date')); } if ($this->request->filled('end_date')) { $model = $model->whereDate('created_at', '<', $this->request->get('end_date')); } return $model; } }