update resource delete command

This commit is contained in:
Andras Bacsai 2023-10-12 13:35:57 +02:00
parent 63de538879
commit b8dd7704b3
4 changed files with 17 additions and 16 deletions

View File

@ -43,23 +43,24 @@ public function handle()
$this->deleteDatabase();
} elseif ($resource === 'Service') {
$this->deleteService();
} elseif($resource === 'Server') {
} elseif ($resource === 'Server') {
$this->deleteServer();
}
}
private function 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(),
label: 'What server do you want to delete?',
options: $servers->pluck('name', 'id')->sortKeys(),
);
foreach ($serversToDelete as $id) {
$toDelete = Server::find($id);
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) {
@ -77,11 +78,12 @@ private function deleteApplication()
}
$applicationsToDelete = multiselect(
'What application do you want to delete?',
$applications->pluck('name')->sort()->toArray(),
$applications->pluck('name', 'id')->sortKeys(),
);
foreach ($applicationsToDelete as $application) {
$toDelete = $applications->where('name', $application)->first();
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) {
@ -99,11 +101,11 @@ private function deleteDatabase()
}
$databasesToDelete = multiselect(
'What database do you want to delete?',
$databases->pluck('name')->sort()->toArray(),
$databases->pluck('name', 'id')->sortKeys(),
);
foreach ($databasesToDelete as $database) {
$toDelete = $databases->where('name', $database)->first();
$toDelete = $databases->where('id', $database)->first();
$this->info($toDelete);
$confirmed = confirm("Are you sure you want to delete all selected resources?");
if (!$confirmed) {
@ -111,7 +113,6 @@ private function deleteDatabase()
}
$toDelete->delete();
}
}
private function deleteService()
{
@ -122,11 +123,11 @@ private function deleteService()
}
$servicesToDelete = multiselect(
'What service do you want to delete?',
$services->pluck('name')->sort()->toArray(),
$services->pluck('name', 'id')->sortKeys(),
);
foreach ($servicesToDelete as $service) {
$toDelete = $services->where('name', $service)->first();
$toDelete = $services->where('id', $service)->first();
$this->info($toDelete);
$confirmed = confirm("Are you sure you want to delete all selected resources?");
if (!$confirmed) {

View File

@ -7,7 +7,7 @@
// The release version of your application
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
'release' => '4.0.0-beta.81',
'release' => '4.0.0-beta.82',
// When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'),

View File

@ -1,3 +1,3 @@
<?php
return '4.0.0-beta.81';
return '4.0.0-beta.82';

View File

@ -4,7 +4,7 @@
"version": "3.12.36"
},
"v4": {
"version": "4.0.0-beta.81"
"version": "4.0.0-beta.82"
}
}
}