Lae/app/Console/Commands/BanUser.php
2022-11-19 12:38:26 +08:00

62 lines
1.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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);
$this->confirm('确定要继续吗?如果继续,将会暂停所有的 Host并且吊销所有 Token。');
$user->banned_at = now();
$user->banned_reason = $reason;
$user->save();
$this->info('封禁用户成功。');
return 0;
}
}