/
evo
/
docviz
Обзор
Документация
Войти
/
evo
/
docviz
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
app/Console/Commands/DeleteUser.php
54 строки
1 KB
evo
Initial commit
04 фев 2026, 17:00
04 фев 2026, 17:00
6132ae5
Код
Авторство
О чём код?
<?php namespace App\Console\Commands; use Illuminate\Console\Command; use App\Models\User; class DeleteUser extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'user:delete {email}'; /** * The console command description. * * @var string */ protected $description = 'Delete a user by email'; /** * Execute the console command. */ public function handle() { $email = $this->argument('email'); $user = User::where('email', $email)->first(); if (!$user) { $this->error("User with email '{$email}' not found."); return 1; } $this->table( ['ID', 'Name', 'Email', 'Role'], [[$user->id, $user->name, $user->email, $user->role]] ); if (!$this->confirm('Are you sure you want to delete this user?')) { $this->info('Deletion cancelled.'); return 0; } $user->delete(); $this->info("User '{$email}' deleted successfully."); return 0; } }