search = $search; $this->store_id = $store_id; } /** * @param $model * @param RepositoryInterface $repository * @return mixed */ public function apply($model, Repository $repository) { if(isset($this->search['keyword']) && $this->search['keyword']) { $keyword = '%'.$this->search['keyword'].'%'; $model = $model->where([['content','like',$keyword],['store_id',$this->store_id]]) ->orwhere([['id','like',$keyword],['store_id',$this->store_id]]) ->orwhere([['user_id','like',$keyword],['store_id',$this->store_id]]) ->orwhere([['title','like',$keyword],['store_id',$this->store_id]]); } else if(isset($this->search['updated_at']) && $this->search['updated_at']) { $model = $model->where('updated_at',$this->search['updated_at']); } else { $model = $model->where([['store_id',$this->store_id]]); } return $model; } }