fix: resourcesdelete command

This commit is contained in:
Andras Bacsai 2023-11-06 10:55:46 +01:00
parent 9c6d8320d8
commit c083acaeef

View File

@ -61,12 +61,14 @@ private function deleteServer()
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;
if ($toDelete) {
$this->info($toDelete);
$confirmed = confirm("Are you sure you want to delete all selected resources?");
if (!$confirmed) {
break;
}
$toDelete->delete();
}
$toDelete->delete();
}
}
private function deleteApplication()
@ -82,14 +84,15 @@ private function deleteApplication()
);
foreach ($applicationsToDelete as $application) {
ray($application);
$toDelete = $applications->where('id', $application)->first();
$this->info($toDelete);
$confirmed = confirm("Are you sure you want to delete all selected resources? ");
if (!$confirmed) {
break;
if ($toDelete) {
$this->info($toDelete);
$confirmed = confirm("Are you sure you want to delete all selected resources? ");
if (!$confirmed) {
break;
}
$toDelete->delete();
}
$toDelete->delete();
}
}
private function deleteDatabase()
@ -106,12 +109,14 @@ private function deleteDatabase()
foreach ($databasesToDelete as $database) {
$toDelete = $databases->where('id', $database)->first();
$this->info($toDelete);
$confirmed = confirm("Are you sure you want to delete all selected resources?");
if (!$confirmed) {
return;
if ($toDelete) {
$this->info($toDelete);
$confirmed = confirm("Are you sure you want to delete all selected resources?");
if (!$confirmed) {
return;
}
$toDelete->delete();
}
$toDelete->delete();
}
}
private function deleteService()
@ -128,12 +133,14 @@ private function deleteService()
foreach ($servicesToDelete as $service) {
$toDelete = $services->where('id', $service)->first();
$this->info($toDelete);
$confirmed = confirm("Are you sure you want to delete all selected resources?");
if (!$confirmed) {
return;
if ($toDelete) {
$this->info($toDelete);
$confirmed = confirm("Are you sure you want to delete all selected resources?");
if (!$confirmed) {
return;
}
$toDelete->delete();
}
$toDelete->delete();
}
}
}