deleteApplication(); } elseif ($resource === 'Database') { $this->deleteDatabase(); } elseif ($resource === 'Service') { $this->deleteService(); } elseif($resource === 'Server') { $this->deleteServer(); } } private function deleteServer() { $servers = Server::all(); if ($servers->count() === 0) { $this->error('There are no applications to delete.'); return; } $serversToDelete = multiselect( 'What server do you want to delete?', $servers->pluck('id')->sort()->toArray(), ); foreach ($serversToDelete as $id) { $toDelete = Server::find($id); $this->info($toDelete); $confirmed = confirm("Are you sure you want to delete all selected resources?"); if (!$confirmed) { break; } $toDelete->delete(); } } private function deleteApplication() { $applications = Application::all(); if ($applications->count() === 0) { $this->error('There are no applications to delete.'); return; } $applicationsToDelete = multiselect( 'What application do you want to delete?', $applications->pluck('name')->sort()->toArray(), ); 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(); } } private function deleteDatabase() { $databases = StandalonePostgresql::all(); if ($databases->count() === 0) { $this->error('There are no databases to delete.'); return; } $databasesToDelete = multiselect( 'What database do you want to delete?', $databases->pluck('name')->sort()->toArray(), ); 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(); } } private function deleteService() { $services = Service::all(); if ($services->count() === 0) { $this->error('There are no services to delete.'); return; } $servicesToDelete = multiselect( 'What service do you want to delete?', $services->pluck('name')->sort()->toArray(), ); 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(); } } }