public function beforeSave($insert) { if (parent::beforeSave($insert)) { if ($this->isNewRecord) { $this->auth_key = Yii::$app->getSecurity()->generateRandomString(); } return true; } return false; }
/** * @return \yii\db\ActiveQuery */ public function getUser() { return $this->hasOne(User::className(), ['id' => 'user_id']); }
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(); }
/** * @inheritdoc */ public function attributeLabels() { return ArrayHelper::merge(parent::attributeLabels(), ['repeatPassword' => Yii::t('app', 'Repeat Password')]); }
public function beforeSave($insert) { if (parent::beforeSave($insert)) { if ($insert) { $this->generateAuthKey(); } return true; } return false; }