$query, ]); $this->load($params); if(!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query2 = [ ]; if(!empty( $this->specializationString )) { $query2 = Project::find() ->select([ 'project.project_id' ], 'DISTINCT') ->joinWith([ 'specializations' ]) ->where([ 'like', 'specialization_name', $this->specializationString, ]) ->asArray() ->column(); } $query->andWhere([ 'user_id' => \Yii::$app->user->getId() ]); // grid filtering conditions $query->andFilterWhere([ 'project_id' => $this->project_id, 'project_pid' => $this->project_pid, 'date_add' => $this->date_add, 'date_end' => $this->date_end, 'user_add_id' => $this->user_add_id, 'view_count' => $this->view_count, 'payment_variant' => $this->payment_variant, 'deadline' => $this->deadline, 'contractual' => $this->contractual, ]); $query->andFilterWhere( [ 'project_id' => $query2, ] ); $query->andFilterWhere([ 'like', 'name', $this->name, ]) ->andFilterWhere([ 'like', 'link', $this->link, ]) ->andFilterWhere([ 'like', 'budget', $this->budget, ]) ->andFilterWhere([ 'like', 'city', $this->city, ]) ->andFilterWhere([ 'like', 'street', $this->street, ]) ->andFilterWhere([ 'like', 'house', $this->house, ]) ->andFilterWhere([ 'like', 'description', $this->description, ]) ->andFilterWhere([ 'like', 'file', $this->file, ]); return $dataProvider; } }