Пример #1
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($this->isNewRecord) {
             $this->auth_key = Yii::$app->getSecurity()->generateRandomString();
         }
         return true;
     }
     return false;
 }
Пример #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUser()
 {
     return $this->hasOne(User::className(), ['id' => 'user_id']);
 }
Пример #3
0
 public function beforeSave($insert)
 {
     parent::beforeSave($insert);
     if ($this->password) {
         $this->hash = \Yii::$app->security->generatePasswordHash($this->password);
     }
     if ($this->isNewRecord && !$this->activation_code) {
         $this->activation_code = md5(\Yii::$app->security->generateRandomString());
     }
     if ($this->isNewRecord && !$this->access_token) {
         $this->access_token = self::generateToken();
     }
     return !$this->hasErrors();
 }
Пример #4
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ArrayHelper::merge(parent::attributeLabels(), ['repeatPassword' => Yii::t('app', 'Repeat Password')]);
 }
Пример #5
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($insert) {
             $this->generateAuthKey();
         }
         return true;
     }
     return false;
 }