6
0
Fork 0
jiqu-library-server/app/Console/Commands/UserClear.php

50 lines
1018 B
PHP

<?php
namespace App\Console\Commands;
use App\Enums\SocialiteType;
use App\Models\User;
use Illuminate\Console\Command;
class UserClear extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'user:clear {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 int
*/
public function handle()
{
$user = User::query()->findOrFail($this->argument('id'));
$user->update(['phone' => null]);
$user->tokens()->delete();
$count = $user->socialites()->where('socialite_type', SocialiteType::WechatMiniProgram->value)->delete();
$this->info($count);
return 0;
}
}