diff --git a/app/Console/Commands/ResourcesDelete.php b/app/Console/Commands/ResourcesDelete.php index 2b71cee89..56e680642 100644 --- a/app/Console/Commands/ResourcesDelete.php +++ b/app/Console/Commands/ResourcesDelete.php @@ -55,14 +55,16 @@ private function deleteServer() { } $serversToDelete = multiselect( 'What server do you want to delete?', - $servers->pluck('id')->toArray(), + $servers->pluck('id')->sort()->toArray(), ); - $confirmed = confirm("Are you sure you want to delete all selected resources?"); - if (!$confirmed) { - return; - } + foreach ($serversToDelete as $server) { $toDelete = $servers->where('id', $server)->first(); + $this->info($toDelete); + $confirmed = confirm("Are you sure you want to delete all selected resources?"); + if (!$confirmed) { + break; + } $toDelete->delete(); } } @@ -75,14 +77,16 @@ private function deleteApplication() } $applicationsToDelete = multiselect( 'What application do you want to delete?', - $applications->pluck('name')->toArray(), + $applications->pluck('name')->sort()->toArray(), ); - $confirmed = confirm("Are you sure you want to delete all selected resources?"); - if (!$confirmed) { - return; - } + foreach ($applicationsToDelete as $application) { $toDelete = $applications->where('name', $application)->first(); + $this->info($toDelete); + $confirmed = confirm("Are you sure you want to delete all selected resources? "); + if (!$confirmed) { + break; + } $toDelete->delete(); } } @@ -95,14 +99,16 @@ private function deleteDatabase() } $databasesToDelete = multiselect( 'What database do you want to delete?', - $databases->pluck('name')->toArray(), + $databases->pluck('name')->sort()->toArray(), ); - $confirmed = confirm("Are you sure you want to delete all selected resources?"); - if (!$confirmed) { - return; - } + foreach ($databasesToDelete as $database) { $toDelete = $databases->where('name', $database)->first(); + $this->info($toDelete); + $confirmed = confirm("Are you sure you want to delete all selected resources?"); + if (!$confirmed) { + return; + } $toDelete->delete(); } @@ -116,14 +122,16 @@ private function deleteService() } $servicesToDelete = multiselect( 'What service do you want to delete?', - $services->pluck('name')->toArray(), + $services->pluck('name')->sort()->toArray(), ); - $confirmed = confirm("Are you sure you want to delete all selected resources?"); - if (!$confirmed) { - return; - } + foreach ($servicesToDelete as $service) { $toDelete = $services->where('name', $service)->first(); + $this->info($toDelete); + $confirmed = confirm("Are you sure you want to delete all selected resources?"); + if (!$confirmed) { + return; + } $toDelete->delete(); } }