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