feat: multiselect removable resources
This commit is contained in:
parent
1651845e20
commit
38e1f17edf
1 changed files with 20 additions and 12 deletions
|
|
@ -8,6 +8,7 @@
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
use function Laravel\Prompts\confirm;
|
use function Laravel\Prompts\confirm;
|
||||||
|
use function Laravel\Prompts\multiselect;
|
||||||
use function Laravel\Prompts\select;
|
use function Laravel\Prompts\select;
|
||||||
|
|
||||||
class ResourcesDelete extends Command
|
class ResourcesDelete extends Command
|
||||||
|
|
@ -50,16 +51,18 @@ private function deleteApplication()
|
||||||
$this->error('There are no applications to delete.');
|
$this->error('There are no applications to delete.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$application = select(
|
$applicationsToDelete = multiselect(
|
||||||
'What application do you want to delete?',
|
'What application do you want to delete?',
|
||||||
$applications->pluck('name')->toArray(),
|
$applications->pluck('name')->toArray(),
|
||||||
);
|
);
|
||||||
$application = $applications->where('name', $application)->first();
|
$confirmed = confirm("Are you sure you want to delete all selected resources?");
|
||||||
$confirmed = confirm("Are you sure you want to delete {$application->name}?");
|
|
||||||
if (!$confirmed) {
|
if (!$confirmed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$application->delete();
|
foreach ($applicationsToDelete as $application) {
|
||||||
|
$toDelete = $applications->where('name', $application)->first();
|
||||||
|
$toDelete->delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private function deleteDatabase()
|
private function deleteDatabase()
|
||||||
{
|
{
|
||||||
|
|
@ -68,16 +71,19 @@ private function deleteDatabase()
|
||||||
$this->error('There are no databases to delete.');
|
$this->error('There are no databases to delete.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$database = select(
|
$databasesToDelete = multiselect(
|
||||||
'What database do you want to delete?',
|
'What database do you want to delete?',
|
||||||
$databases->pluck('name')->toArray(),
|
$databases->pluck('name')->toArray(),
|
||||||
);
|
);
|
||||||
$database = $databases->where('name', $database)->first();
|
$confirmed = confirm("Are you sure you want to delete all selected resources?");
|
||||||
$confirmed = confirm("Are you sure you want to delete {$database->name}?");
|
|
||||||
if (!$confirmed) {
|
if (!$confirmed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$database->delete();
|
foreach ($databasesToDelete as $database) {
|
||||||
|
$toDelete = $databases->where('name', $database)->first();
|
||||||
|
$toDelete->delete();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private function deleteService()
|
private function deleteService()
|
||||||
{
|
{
|
||||||
|
|
@ -86,15 +92,17 @@ private function deleteService()
|
||||||
$this->error('There are no services to delete.');
|
$this->error('There are no services to delete.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$service = select(
|
$servicesToDelete = multiselect(
|
||||||
'What service do you want to delete?',
|
'What service do you want to delete?',
|
||||||
$services->pluck('name')->toArray(),
|
$services->pluck('name')->toArray(),
|
||||||
);
|
);
|
||||||
$service = $services->where('name', $service)->first();
|
$confirmed = confirm("Are you sure you want to delete all selected resources?");
|
||||||
$confirmed = confirm("Are you sure you want to delete {$service->name}?");
|
|
||||||
if (!$confirmed) {
|
if (!$confirmed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$service->delete();
|
foreach ($servicesToDelete as $service) {
|
||||||
|
$toDelete = $services->where('name', $service)->first();
|
||||||
|
$toDelete->delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue