优化 封禁逻辑
This commit is contained in:
parent
82b2a3a954
commit
dc9ad81cb6
@ -49,23 +49,14 @@ public function handle()
|
|||||||
|
|
||||||
$this->info('封禁: ' . $user->name);
|
$this->info('封禁: ' . $user->name);
|
||||||
|
|
||||||
$this->confirm('确定要继续吗?如果继续,将会暂停所有的 Host。');
|
$this->confirm('确定要继续吗?如果继续,将会暂停所有的 Host,并且吊销所有 Token。');
|
||||||
|
|
||||||
$user->banned_at = now();
|
$user->banned_at = now();
|
||||||
$user->banned_reason = $reason;
|
$user->banned_reason = $reason;
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
$this->info('正在暂停所有的 Host...');
|
|
||||||
Host::where('user_id', $user_id)->update([
|
|
||||||
'status' => 'suspended',
|
|
||||||
'suspended_at' => now()
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->info('正在吊销所有 Token...');
|
|
||||||
|
|
||||||
$user->tokens()->delete();
|
|
||||||
|
|
||||||
$this->info('封禁用户成功。');
|
$this->info('封禁用户成功。');
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,16 @@ protected static function boot()
|
|||||||
|
|
||||||
// balance 四舍五入
|
// balance 四舍五入
|
||||||
$model->balance = round($model->balance, 2);
|
$model->balance = round($model->balance, 2);
|
||||||
|
|
||||||
|
if ($model->banned_at) {
|
||||||
|
Host::where('user_id', $model->id)->update([
|
||||||
|
'status' => 'suspended',
|
||||||
|
'suspended_at' => now()
|
||||||
|
]);
|
||||||
|
|
||||||
|
$model->tokens()->delete();
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user