protected $signature = 'manage:ban {--uid=: the user you want to ban} {--time=: Unban time, Supports time that can be resolved by the strtotime method} {--reason=: reason}';
17
18
/**
19
* The console command description.
20
*
21
* @var string
22
*/
23
protected $description = 'Ban a user';
24
25
/**
26
* Create a new command instance.
27
*
28
* @return void
29
*/
30
public function __construct()
31
{
32
parent::__construct();
33
}
34
35
/**
36
* Execute the console command.
37
*
38
* @return mixed
39
*/
40
public function handle()
41
{
42
$uid=(int)$this->option('uid');
43
$reason=$this->option('reason');
44
$time=$this->option('time');
45
$user = User::find($uid);
46
if(empty($user)) {
47
$this->line("\n <bg=red;fg=white> Exception </> : <fg=yellow>User Not Found</>\n");
48
return;
49
}
50
try{
51
$ban_time = date('Y-m-d H:i:s',strtotime($time));
52
UserBanned::create([
53
'user_id' => $user->id,
54
'reason' => $reason,
55
'removed_at' => $ban_time
56
]);
57
$this->line("The user <fg=yellow>{$user->name}</> will be banned until <fg=yellow>{$ban_time}</>");