コード例 #1
0
ファイル: BankSearch.php プロジェクト: 92Sam/casein-v2
 /**
  * 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
ファイル: BankController.php プロジェクト: 92Sam/casein-v2
 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);
 }