Example #1
0
 public function search($params)
 {
     $query = BankUser::find();
     if (!isset($params['sort'])) {
         $query->orderBy(['bank_user.id_bank' => SORT_DESC]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     if (@$params['BankUserSearch']['id_user']) {
         $query->andFilterWhere(["user.first_name" => $params['BankUserSearch']['id_user']]);
     }
     if (@$params['BankUserSearch']['id_bank']) {
         $query->andFilterWhere(["bank.name" => $params['BankUserSearch']['id_bank']]);
     }
     $query->select('user.first_name,user.mid_name,user.last_name,user.email,bank.name,bank_user.*')->join("LEFT JOIN", 'bank', "bank.id_bank=bank_user.id_bank")->join("LEFT JOIN", 'user', "user.id_user=bank_user.id_user")->all();
     return $dataProvider;
 }
Example #2
0
 public function getInfo()
 {
     switch ($this->id_user_role) {
         case Dict::USER_ROLE_BETTERDEBT:
             return $this->hasOne(Betterdebt::classname(), ['id_user' => 'id_user']);
             break;
         case Dict::USER_ROLE_ADVISOR:
             return $this->hasOne(Advisor::classname(), ['id_user' => 'id_user']);
             break;
         case Dict::USER_ROLE_CLIENT:
             return $this->hasOne(Client::classname(), ['id_user' => 'id_user']);
             break;
         case Dict::USER_ROLE_BANK:
             return $this->hasOne(BankUser::classname(), ['id_user' => 'id_user']);
             break;
         default:
             return null;
             break;
     }
 }
 public function actionDelete($id)
 {
     $model = BankUser::find()->where(['id' => $id])->one();
     $model->delete = 1;
     $model->save();
     return $this->redirect(['index']);
 }