From bddd6af8af93c2eb482475dd7ae57e39a0a4ccc4 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 29 Jul 2024 12:13:08 +0200 Subject: [PATCH] Fix user deletion in no interactive mode (#506) --- app/Console/Commands/User/DeleteUserCommand.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/User/DeleteUserCommand.php b/app/Console/Commands/User/DeleteUserCommand.php index a6810feee..8c85510ed 100644 --- a/app/Console/Commands/User/DeleteUserCommand.php +++ b/app/Console/Commands/User/DeleteUserCommand.php @@ -15,7 +15,7 @@ class DeleteUserCommand extends Command public function handle(): int { $search = $this->option('user') ?? $this->ask(trans('command/messages.user.search_users')); - Assert::notEmpty($search, 'Search term should be an email address, got: %s.'); + Assert::notEmpty($search, 'Search term should not be empty.'); $results = User::query() ->where('id', 'LIKE', "$search%") @@ -42,6 +42,8 @@ class DeleteUserCommand extends Command if (!$deleteUser = $this->ask(trans('command/messages.user.select_search_user'))) { return $this->handle(); } + + $deleteUser = User::query()->findOrFail($deleteUser); } else { if (count($results) > 1) { $this->error(trans('command/messages.user.multiple_found')); @@ -53,8 +55,7 @@ class DeleteUserCommand extends Command } if ($this->confirm(trans('command/messages.user.confirm_delete')) || !$this->input->isInteractive()) { - $user = User::query()->findOrFail($deleteUser); - $user->delete(); + $deleteUser->delete(); $this->info(trans('command/messages.user.deleted')); }