2022-09-13 11:32:58 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
|
|
class BanUser extends Command
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* The name and signature of the console command.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $signature = 'ban {user_id} {reason}';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The console command description.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $description = '封禁一个用户。';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new command instance.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
parent::__construct();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Execute the console command.
|
|
|
|
|
*
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public function handle()
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
$user_id = $this->argument('user_id');
|
|
|
|
|
|
|
|
|
|
$reason = $this->argument('reason');
|
|
|
|
|
|
|
|
|
|
$user = User::find($user_id);
|
|
|
|
|
|
|
|
|
|
$this->info('封禁: ' . $user->name);
|
|
|
|
|
|
2022-11-18 08:29:57 +00:00
|
|
|
|
$this->confirm('确定要继续吗?如果继续,将会暂停所有的 Host,并且吊销所有 Token。');
|
2022-09-13 11:32:58 +00:00
|
|
|
|
|
|
|
|
|
$user->banned_at = now();
|
|
|
|
|
$user->banned_reason = $reason;
|
|
|
|
|
$user->save();
|
|
|
|
|
|
|
|
|
|
$this->info('封禁用户成功。');
|
|
|
|
|
|
2022-11-18 08:29:57 +00:00
|
|
|
|
return 0;
|
2022-09-13 11:32:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|