Example #1
0
 protected function getModelAttributesFromPost(BaseModel $model)
 {
     if (\Yii::$app->request->isPost) {
         return \Yii::$app->request->post($model->getShortClassName());
     }
     return false;
 }
Example #2
0
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if ($this->getAttribute('delete') == 1 && $changedAttributes['delete'] == 0) {
         $user = $this->user;
         $user->delete = 1;
         $user->save();
     }
 }
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->created_at = new Expression('NOW()');
     } else {
         $this->updated_at = new Expression('NOW()');
     }
     return parent::beforeValidate();
 }
Example #4
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         //ssn加密
         if ($this->social_security_number) {
             $this->social_security_number = Aes::encode($this->social_security_number);
         }
     }
     return true;
 }
Example #5
0
 public function attributes()
 {
     $attributes = parent::attributes();
     foreach ($attributes as $key => $attribute) {
         if ($attribute === 'password_hash') {
             unset($attributes[$key]);
         }
     }
     return $attributes;
 }
Example #6
0
 public static function find($onlyDeleted = null)
 {
     if (is_null($onlyDeleted)) {
         return parent::find()->where([self::tableName() . '.delete' => 0]);
     } elseif ($onlyDeleted === true) {
         return parent::find()->where([self::tableName() . '.delete' => 1]);
     } elseif ($onlyDeleted === false) {
         return parent::find();
     }
 }
Example #7
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($insert) {
             $this->requested_date = time();
         }
         return true;
     } else {
         return false;
     }
 }
Example #8
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($this->getAttribute('delete') == 1 && $this->getOldAttribute('delete') == 0) {
             if ($this->applications) {
                 return false;
             }
         }
         return true;
     }
 }
Example #9
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($this->getAttribute('delete') == 1 && $this->getOldAttribute('delete') == 0) {
             if (isset($this->advisor)) {
                 if ($applications = $this->advisor->primaryApplications) {
                     $idGroupArray = ArrayHelper::map($applications, 'id_group', 'id_group');
                     foreach ($idGroupArray as $idGroup) {
                         if ($idGroup == $this->id_group) {
                             return false;
                         }
                     }
                 }
             }
         }
         return true;
     }
 }
Example #10
0
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if ($this->getAttribute('delete') == 1 && $changedAttributes['delete'] == 0) {
         $user = $this->user;
         $user->delete = 1;
         $user->save();
         if ($advisorGroups = $this->advisorGroups) {
             foreach ($advisorGroups as $advisorGroup) {
                 $advisorGroup->delete = 1;
                 $advisorGroup->save();
             }
         }
     }
 }
Example #11
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         //applicant创建时与client同步数据
         if ($insert) {
             $clientModel = $this->client;
             $this->load([$this->formName() => $clientModel->getAttributes()]);
         }
         $this->date_of_birth = is_numeric($this->date_of_birth) ? $this->date_of_birth : strtotime($this->date_of_birth);
         $this->identification_expiration_date = is_numeric($this->identification_expiration_date) ? $this->identification_expiration_date : strtotime($this->identification_expiration_date);
         //ssn加密
         if ($this->social_security_number) {
             $this->social_security_number = Aes::encode($this->social_security_number);
         }
     }
     return true;
 }
Example #12
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($this->getIsNewRecord()) {
             $this->setPassword($this->password_hash);
         }
         return true;
     } else {
         return false;
     }
 }
Example #13
0
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if (!$insert) {
         if (isset($changedAttributes['delete']) && $changedAttributes['delete'] == 0 && $this->delete == 1) {
             //删除application时,同步删除抵押账户以及line
             AppFormCollateralAccount::updateAll(['delete' => 1], 'id_application = ' . $this->id_application);
             if ($this->loan) {
                 $this->loan->delete = 1;
                 $this->loan->save();
             }
             if ($this->appApplicants) {
                 foreach ($this->appApplicants as $applicant) {
                     $applicant->delete = 1;
                     $applicant->save();
                 }
             }
         }
     }
 }
Example #14
0
 /**
  * @inheritdoc
  */
 public function attributeHints()
 {
     return array_merge(parent::attributeHints(), ['user_id' => \Yii::t('common', 'User Id'), 'code' => \Yii::t('common', 'Code'), 'created_at' => \Yii::t('common', 'Created At'), 'type' => \Yii::t('common', 'Type')]);
 }
Example #15
0
 /**
  * @inheritdoc
  */
 public function attributeHints()
 {
     return array_merge(parent::attributeHints(), ['id' => \Yii::t('common', 'ID'), 'user_id' => \Yii::t('common', 'User Id'), 'provider' => \Yii::t('common', 'Provider'), 'client_id' => \Yii::t('common', 'Client Id'), 'data' => \Yii::t('common', 'Data'), 'code' => \Yii::t('common', 'Code'), 'created_at' => \Yii::t('common', 'Created At'), 'email' => \Yii::t('common', 'Email'), 'username' => \Yii::t('common', 'Username')]);
 }
Example #16
0
 /**
  * @inheritdoc
  */
 public function attributeHints()
 {
     return array_merge(parent::attributeHints(), ['user_id' => \Yii::t('common', 'User Id'), 'name' => \Yii::t('common', 'Name'), 'public_email' => \Yii::t('common', 'Public Email'), 'gravatar_email' => \Yii::t('common', 'Gravatar Email'), 'gravatar_id' => \Yii::t('common', 'Gravatar Id'), 'location' => \Yii::t('common', 'Location'), 'website' => \Yii::t('common', 'Website'), 'bio' => \Yii::t('common', 'Bio')]);
 }
Example #17
0
 /**
  * @inheritdoc
  */
 public function attributeHints()
 {
     return array_merge(parent::attributeHints(), ['id' => \Yii::t('common', 'ID'), 'username' => \Yii::t('common', 'Username'), 'email' => \Yii::t('common', 'Email'), 'password_hash' => \Yii::t('common', 'Password Hash'), 'auth_key' => \Yii::t('common', 'Auth Key'), 'confirmed_at' => \Yii::t('common', 'Confirmed At'), 'unconfirmed_email' => \Yii::t('common', 'Unconfirmed Email'), 'blocked_at' => \Yii::t('common', 'Blocked At'), 'registration_ip' => \Yii::t('common', 'Registration Ip'), 'created_at' => \Yii::t('common', 'Created At'), 'updated_at' => \Yii::t('common', 'Updated At'), 'flags' => \Yii::t('common', 'Flags')]);
 }
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         //置空未选择的账户类型相关字段
         if (!$this->is_trust_account) {
             $this->trust_name = '';
             $this->names_of_grantors = '';
             $this->names_of_trustees = '';
             $this->tax_id = '';
             $this->address_street = '';
             $this->address_state_where_organized = '';
             $this->address_city = '';
             $this->address_state = '';
             $this->address_zip_code = '';
             $this->trustee_phone_number = '';
         }
         if (!$this->has_regular_distribution) {
             $this->payee = '';
             $this->regular_distribution_amount = '';
         }
     }
     return true;
 }