Lae/app/Console/Commands/UnbanUser.php

55 lines
964 B
PHP
Raw Normal View History

2022-09-13 11:43:31 +00:00
<?php
namespace App\Console\Commands;
use App\Models\User;
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.
*
2022-12-11 11:47:30 +00:00
* @return void
2022-09-13 11:43:31 +00:00
*/
2023-01-10 13:42:27 +00:00
public function handle(): void
2022-09-13 11:43:31 +00:00
{
//
$user_id = $this->argument('user_id');
2023-01-10 13:42:27 +00:00
$user = (new User)->find($user_id);
2022-09-13 11:43:31 +00:00
2023-02-07 09:04:11 +00:00
$this->info('解除封禁: '.$user->name);
2022-09-13 11:43:31 +00:00
$user->banned_at = null;
$user->save();
$this->info('用户已解除封禁。');
}
}