Authored by wuxiao

Admin::findOne()->updateAttributes()

... ... @@ -32,6 +32,8 @@ class AdminController extends BaseController
$model->setPassword($posts['password']);
$model->generateAuthKey();
$model->generatePasswordResetToken();
//用户加入后默认启用状态
$model->status = Admin::STATUS_ACTIVE;
if ($model->save()){
if (($roleName = Yii::$app->request->post('role')) && ($role = $this->authManager->getRole($roleName))){
... ... @@ -120,10 +122,10 @@ class AdminController extends BaseController
$authManager = $this->authManager;
switch (true){
case $target == 'user' && $type == 'disable':
$r = Admin::findOne(Yii::$app->getRequest()->getQueryParam('id'))->updateAll(['status'=>Admin::STATUS_DELETED]);
$r = Admin::findOne(Yii::$app->getRequest()->getQueryParam('id'))->updateAttributes(['status'=>Admin::STATUS_DELETED]);
break;
case $target == 'user' && $type == 'enable':
$r = Admin::findOne(Yii::$app->getRequest()->getQueryParam('id'))->updateAll(['status'=>Admin::STATUS_ACTIVE]);
$r = Admin::findOne(Yii::$app->getRequest()->getQueryParam('id'))->updateAttributes(['status'=>Admin::STATUS_ACTIVE]);
break;
case $target == 'user' && $type == 'del':
$r = Admin::findOne(Yii::$app->getRequest()->getQueryParam('id'))->delete();
... ...
... ... @@ -38,6 +38,7 @@ class Admin extends \yii\db\ActiveRecord implements \yii\web\IdentityInterface
public function rules()
{
return [
[['username','email'], 'trim'],
[['username', 'auth_key', 'password_hash', 'email'], 'required'],
[['role', 'status', 'create_time', 'update_time'], 'integer'],
[['username', 'password_hash', 'password_reset_token', 'email'], 'string', 'max' => 255],
... ...