Exemplo n.º 1
0
 /**
  * @inheritdoc
  *
  * 管理员模型共有3个场景:
  *
  * - 新增用户:必须要填写密码
  * - 编辑用户:可以不填写密码
  * - 修改密码:只要激活用户和密码字段
  */
 public function scenarios()
 {
     $scenario = parent::scenarios();
     $scenario['create'] = ['username', 'password', 'email', 'status'];
     $scenario['update'] = ['username', 'email', 'status'];
     $scenario['resetPwd'] = ['username', 'password'];
     return $scenario;
 }
Exemplo n.º 2
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($this->isNewRecord) {
             $this->generateAuthKey();
         }
         return true;
     }
     return false;
 }
 /**
  * Does remove record from db
  * @return false|int
  * @throws \Exception
  */
 public function forceDelete()
 {
     return parent::delete();
 }