Lae/app/Console/Commands/SuspendUserAllHosts.php

53 lines
975 B
PHP
Raw Normal View History

2022-09-13 11:32:58 +00:00
<?php
namespace App\Console\Commands;
use App\Models\Host;
use Illuminate\Console\Command;
class SuspendUserAllHosts extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'user:suspended {user_id}';
/**
* The console command description.
*
* @var string
*/
2022-12-28 13:17:54 +00:00
protected $description = '暂停用户的所有主机。';
2022-09-13 11:32:58 +00:00
/**
* 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:32:58 +00:00
*/
public function handle()
{
//
$user_id = $this->argument('user_id');
Host::where('user_id', $user_id)->update([
'status' => 'suspended',
'suspended_at' => now()
]);
2022-12-28 13:17:54 +00:00
$this->info('暂停用户的所有主机成功。');
2022-09-13 11:32:58 +00:00
}
}