public function search_view($params) { //->where(['id_project' => $params['id']] // выборка по проэкту /*Campaigns::find()->with('author')->where(['id_project' => $params['id']])*/ $query = Campaigns::find(); $query->joinWith(['author']); $query->joinWith(['spheres']); $query->where(['id_project' => $params['id']]); $query->orderBy("date_post DESC"); $dataProvider = new ActiveDataProvider(['query' => $query]); // Important: here is how we set up the sorting // The key is the attribute name on our "TourSearch" instance $dataProvider->sort->attributes['author'] = ['asc' => ['user.username' => SORT_ASC], 'desc' => ['user.username' => SORT_DESC]]; // Important: here is how we set up the sorting // The key is the attribute name on our "TourSearch" instance $dataProvider->sort->attributes['spheres'] = ['asc' => ['spheres.name' => SORT_ASC], 'desc' => ['spheres.name' => SORT_DESC]]; $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; } $query->andFilterWhere(['id' => $this->id, 'date_post' => $this->date_post, 'date_end' => $this->date_end, 'date_begin' => $this->date_begin, 'date_update' => $this->date_update, 'id_project' => $this->id_project, 'id_user' => $this->id_user, 'id_sphere' => $this->id_sphere]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'about', $this->about])->andFilterWhere(['like', 'link', $this->link])->andFilterWhere(['like', 'user.username', $this->author])->andFilterWhere(['like', 'spheres.name', $this->spheres]); return $dataProvider; }