/** * @inheritdoc */ public function rules() { return [['active', 'default', 'value' => Cms::BOOL_Y], ['gender', 'default', 'value' => 'men'], ['gender', 'in', 'range' => ['men', 'women']], [['created_at', 'updated_at', 'image_id'], 'integer'], [['info', 'gender', 'status_of_life'], 'string'], [['username', 'password_hash', 'password_reset_token', 'email', 'name', 'city', 'address'], 'string', 'max' => 255], [['auth_key'], 'string', 'max' => 32], [['phone'], 'string'], [['phone'], PhoneValidator::className()], [['phone'], 'unique', 'targetClass' => CmsUserPhone::className(), 'targetAttribute' => 'value', 'filter' => function (ActiveQuery $query) { if ($this->cmsUserPhone) { $query->andWhere(['!=', 'id', $this->cmsUserPhone->id]); } }], [['email'], 'unique', 'targetClass' => CmsUserEmail::className(), 'targetAttribute' => 'value', 'filter' => function (ActiveQuery $query) { if ($this->cmsUserEmail) { $query->andWhere(['!=', 'id', $this->cmsUserEmail->id]); } }], [['email'], 'email'], ['username', 'string', 'min' => 3, 'max' => 12], [['username'], 'unique'], [['username'], \skeeks\cms\validators\LoginValidator::className()], [['logged_at'], 'integer'], [['last_activity_at'], 'integer'], [['last_admin_activity_at'], 'integer'], [['username'], 'default', 'value' => function (self $model) { $userLast = static::find()->orderBy("id DESC")->one(); return "id" . ($userLast->id + 1); }], [['auth_key'], 'default', 'value' => function (self $model) { return \Yii::$app->security->generateRandomString(); }], [['password_hash'], 'default', 'value' => function (self $model) { return \Yii::$app->security->generatePasswordHash(\Yii::$app->security->generateRandomString()); }], [['roleNames'], 'safe']]; }
/** * @inheritdoc */ public function rules() { return [['active', 'default', 'value' => Cms::BOOL_Y], ['gender', 'default', 'value' => 'men'], ['gender', 'in', 'range' => ['men', 'women']], [['username', 'auth_key', 'password_hash'], 'required'], [['created_at', 'updated_at', 'image_id'], 'integer'], [['info', 'gender', 'status_of_life'], 'string'], [['username', 'password_hash', 'password_reset_token', 'email', 'name', 'city', 'address'], 'string', 'max' => 255], [['auth_key'], 'string', 'max' => 32], [['phone'], 'string'], [['phone'], PhoneValidator::className()], [['phone'], 'unique', 'targetClass' => CmsUserPhone::className(), 'targetAttribute' => 'value', 'filter' => function (ActiveQuery $query) { if ($this->cmsUserPhone) { $query->andWhere(['!=', 'id', $this->cmsUserPhone->id]); } }], [['email'], 'unique', 'targetClass' => CmsUserEmail::className(), 'targetAttribute' => 'value', 'filter' => function (ActiveQuery $query) { if ($this->cmsUserEmail) { $query->andWhere(['!=', 'id', $this->cmsUserEmail->id]); } }], [['email'], 'email'], [['username'], 'required'], ['username', 'string', 'min' => 3, 'max' => 12], [['username'], 'unique'], [['username'], \skeeks\cms\validators\LoginValidator::className()], [['logged_at'], 'integer'], [['last_activity_at'], 'integer'], [['last_admin_activity_at'], 'integer']]; }
/** * @inheritdoc */ public function rules() { return [['active', 'default', 'value' => Cms::BOOL_Y], ['gender', 'default', 'value' => 'men'], ['gender', 'in', 'range' => ['men', 'women']], [['created_at', 'updated_at', 'image_id', 'email_is_approved', 'phone_is_approved'], 'integer'], [['gender'], 'string'], [['username', 'password_hash', 'password_reset_token', 'email', 'name'], 'string', 'max' => 255], [['auth_key'], 'string', 'max' => 32], [['phone'], 'string', 'max' => 64], [['phone'], PhoneValidator::className()], [['phone'], 'unique'], [['phone', 'email'], 'default', 'value' => null], [['email'], 'unique'], [['email'], 'email'], ['username', 'string', 'min' => 3, 'max' => 25], [['username'], 'unique'], [['username'], \skeeks\cms\validators\LoginValidator::className()], [['logged_at'], 'integer'], [['last_activity_at'], 'integer'], [['last_admin_activity_at'], 'integer'], [['username'], 'default', 'value' => function (self $model) { $userLast = static::find()->orderBy("id DESC")->one(); return "id" . ($userLast->id + 1); }], [['email_is_approved', 'phone_is_approved'], 'default', 'value' => 0], [['auth_key'], 'default', 'value' => function (self $model) { return \Yii::$app->security->generateRandomString(); }], [['password_hash'], 'default', 'value' => function (self $model) { return \Yii::$app->security->generatePasswordHash(\Yii::$app->security->generateRandomString()); }], [['roleNames'], 'safe'], [['roleNames'], 'default', 'value' => \Yii::$app->cms->registerRoles]]; }