From 8c8746b8c918af22e8d0f0cdcc68da483344de23 Mon Sep 17 00:00:00 2001 From: Axel Date: Wed, 5 Jul 2023 21:52:55 +0200 Subject: [PATCH] Delete user command --- app/Console/Commands/DeleteUser.php | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 app/Console/Commands/DeleteUser.php diff --git a/app/Console/Commands/DeleteUser.php b/app/Console/Commands/DeleteUser.php new file mode 100644 index 0000000..38f2c66 --- /dev/null +++ b/app/Console/Commands/DeleteUser.php @@ -0,0 +1,45 @@ +argument('login'))->first(); + if (empty($user)) { + $this->error('No such user "'.$this->argument('login').'"'); + } + else { + try { + $user->delete(); + $this->info('User "'.$this->argument('login').'" has been deleted'); + } + catch (Exception $e) { + $this->error('Could not delete user "'.$this->argument('login').'"'); + } + } + + } +}