예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Bank::find();
     $dataProvider = new ActiveDataProvider(['query' => $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;
     }
     $query->andFilterWhere(['id' => $this->id, 'country_id' => $this->country_id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'bank_data', $this->bank_data]);
     return $dataProvider;
 }
예제 #2
0
 public function actionBankslistbycountryid($countryId)
 {
     if ($countryId != NULL) {
         $model = Bank::find()->where(['country_id' => $countryId])->all();
         //$countBank = $model->count();
         //$countBank = 1;
         //if($countBank > 0){
         //$model = $model->all();
         $data = [];
         foreach ($model as $key => $value) {
             $data[$key] = ['id' => $value['id'], 'name' => $value['name']];
         }
         //}else{$model = NULL;}
     } else {
         $model = NULL;
     }
     return json_encode($data);
 }