6
0
Fork 0
release
李静 2022-01-04 14:08:03 +08:00
parent 7a6fd399cb
commit 1592f13ff5
1 changed files with 13 additions and 14 deletions

View File

@ -25,6 +25,7 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac
public const STATUS_FROZEN = -1; // 冻结 public const STATUS_FROZEN = -1; // 冻结
public const STATUS_INACTIVATED = 0; // 未激活 public const STATUS_INACTIVATED = 0; // 未激活
public const STATUS_ACTIVE = 1; // 正常 public const STATUS_ACTIVE = 1; // 正常
public const STATUS_DISABLED = 2; // 禁用
/** /**
* @var array * @var array
@ -273,19 +274,17 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac
/** /**
* 禁用用户 * 禁用用户
* *
* @param string|null $status_remarks * @param string|null $statusRemark
* @return void * @return void
*/ */
public function disable(?string $status_remark = null) public function disable(?string $statusRemark = null)
{ {
$res = null; if ($this->status === static::STATUS_ACTIVE) {
if ($this->status == 1) {//只操作正常用户 $this->update([
$this->status = 2; 'status' => static::STATUS_DISABLED,
$this->status_remark = $status_remark; 'status_remark' => $statusRemark,
$res = $this->save(); ]);
} }
return $res;
} }
/** /**
@ -295,12 +294,12 @@ class User extends Model implements AuthorizableContract, AuthenticatableContrac
*/ */
public function enable() public function enable()
{ {
$res = null; if ($this->status !== static::STATUS_ACTIVE) {
if ($this->status != 1) {// return $this->update([
$this->status = 1; 'status' => static::STATUS_DISABLED,
$res = $this->save(); 'status_remark' => null,
]);
} }
return $res;
} }
/** /**