Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = City::find()->joinWith(['country']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'country_id' => $this->country_id]);
     $query->andFilterWhere(['like', City::tableName() . '.title', $this->title])->andFilterWhere(['like', Country::tableName() . '.title', $this->country]);
     return $dataProvider;
 }