Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = RgnCity::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 50]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'province_id' => $this->province_id]);
     $query->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'number', $this->number])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'abbreviation', $this->abbreviation]);
     return $dataProvider;
 }
Пример #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = RgnCity::find()->with('province');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 50]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['rgn_city.id' => $this->id]);
     $query->andFilterWhere(['like', 'rgn_city.recordStatus', $this->recordStatus])->andFilterWhere(['like', 'rgn_city.number', $this->number])->andFilterWhere(['like', 'rgn_city.name', $this->name])->andFilterWhere(['like', 'rgn_city.abbreviation', $this->abbreviation]);
     if (is_integer($this->province_id)) {
         $query->andFilterWhere(['province_id' => $this->province_id]);
     } else {
         if ($this->province_id) {
             $query->joinWith(['province' => function ($q) {
                 $q->where('rgn_province.name LIKE "%' . $this->province_id . '%"');
             }]);
         }
     }
     return $dataProvider;
 }