解除封禁用户

This commit is contained in:
iVampireSP.com 2022-09-13 19:43:31 +08:00
parent 6c82b8afb5
commit 20610b1c37
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
2 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,59 @@
<?php
namespace App\Console\Commands;
use App\Models\Host;
use App\Models\User;
use App\Models\AccessToken;
use Illuminate\Console\Command;
class UnbanUser extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'unban {user_id}';
/**
* 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);
$user->banned_at = null;
$user->banned_reason = $reason;
$user->save();
$this->info('用户已解除封禁。');
}
}

View File

@ -4,6 +4,7 @@
use App\Console\Commands\BanUser;
use App\Console\Commands\SuspendUserAllHosts;
use App\Console\Commands\UnbanUser;
use App\Jobs\HostCost;
use App\Jobs\ClearTasks;
use App\Jobs\DeleteHost;
@ -21,6 +22,7 @@ class Kernel extends ConsoleKernel
protected $commands = [
//
BanUser::class,
UnbanUser::class,
SuspendUserAllHosts::class
];