lasthourcloud/app/Livewire/Project/Shared/Danger.php

47 lines
1.2 KiB
PHP
Raw Normal View History

2023-05-18 11:26:35 +00:00
<?php
2023-12-07 18:06:32 +00:00
namespace App\Livewire\Project\Shared;
2023-05-18 11:26:35 +00:00
use App\Jobs\DeleteResourceJob;
2023-05-18 11:26:35 +00:00
use Livewire\Component;
2023-07-13 11:16:24 +00:00
use Visus\Cuid2\Cuid2;
2023-05-18 11:26:35 +00:00
class Danger extends Component
{
2023-08-07 20:14:21 +00:00
public $resource;
2024-06-10 20:43:34 +00:00
2023-12-11 08:41:31 +00:00
public $projectUuid;
2024-06-10 20:43:34 +00:00
2023-12-11 08:41:31 +00:00
public $environmentName;
2024-06-10 20:43:34 +00:00
public bool $delete_configurations = true;
2024-06-10 20:43:34 +00:00
2024-07-11 10:38:54 +00:00
public bool $delete_volumes = true;
public ?string $modalId = null;
2023-05-22 10:47:15 +00:00
public function mount()
{
2023-07-13 11:16:24 +00:00
$this->modalId = new Cuid2(7);
2023-12-11 08:41:31 +00:00
$parameters = get_route_parameters();
2024-01-31 13:22:48 +00:00
$this->projectUuid = data_get($parameters, 'project_uuid');
$this->environmentName = data_get($parameters, 'environment_name');
2023-05-22 10:47:15 +00:00
}
2024-06-10 20:43:34 +00:00
2023-05-22 10:47:15 +00:00
public function delete()
{
2023-09-22 09:23:49 +00:00
try {
2024-05-24 12:15:16 +00:00
// $this->authorize('delete', $this->resource);
$this->resource->delete();
2024-07-11 10:38:54 +00:00
DeleteResourceJob::dispatch($this->resource, $this->delete_configurations, $this->delete_volumes);
2024-06-10 20:43:34 +00:00
2024-01-07 15:23:41 +00:00
return redirect()->route('project.resource.index', [
2023-12-11 08:41:31 +00:00
'project_uuid' => $this->projectUuid,
2024-06-10 20:43:34 +00:00
'environment_name' => $this->environmentName,
2023-12-27 15:45:01 +00:00
]);
2023-09-22 09:23:49 +00:00
} catch (\Throwable $e) {
return handleError($e, $this);
2023-09-22 09:23:49 +00:00
}
2023-05-22 10:47:15 +00:00
}
2023-05-18 11:26:35 +00:00
}