Ejemplo n.º 1
0
 public function unique_projects()
 {
     $name = Yii::$app->request->post();
     $id_project = Yii::$app->request->post();
     $password = Campaigns::find()->where(['name' => $name['Campaigns']['name'], 'id_project' => $id_project['Campaigns']['id_project'], 'id_user' => Yii::$app->user->identity['id']])->one();
     return $password->id_project;
 }
 public function search_view($params)
 {
     //->where(['id_project' => $params['id']] // выборка по проэкту
     /*Campaigns::find()->with('author')->where(['id_project' => $params['id']])*/
     $query = Campaigns::find();
     $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['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', 'unique_link', $this->unique_link])->andFilterWhere(['like', 'link', $this->link])->andFilterWhere(['like', 'spheres.name', $this->spheres]);
     return $dataProvider;
 }