2023-05-18 13:26:35 +02:00
|
|
|
<?php
|
|
|
|
|
2023-12-07 19:06:32 +01:00
|
|
|
namespace App\Livewire\Project\Shared;
|
2023-05-18 13:26:35 +02:00
|
|
|
|
2023-11-06 11:51:20 +01:00
|
|
|
use App\Jobs\DeleteResourceJob;
|
2023-05-18 13:26:35 +02:00
|
|
|
use Livewire\Component;
|
2023-07-13 13:16:24 +02:00
|
|
|
use Visus\Cuid2\Cuid2;
|
2023-05-18 13:26:35 +02:00
|
|
|
|
|
|
|
class Danger extends Component
|
|
|
|
{
|
2023-08-07 22:14:21 +02:00
|
|
|
public $resource;
|
2023-12-11 09:41:31 +01:00
|
|
|
public $projectUuid;
|
|
|
|
public $environmentName;
|
2023-10-14 14:22:07 +02:00
|
|
|
public ?string $modalId = null;
|
2023-05-22 12:47:15 +02:00
|
|
|
|
|
|
|
public function mount()
|
|
|
|
{
|
2023-07-13 13:16:24 +02:00
|
|
|
$this->modalId = new Cuid2(7);
|
2023-12-11 09:41:31 +01:00
|
|
|
$parameters = get_route_parameters();
|
|
|
|
$this->projectUuid = $parameters['project_uuid'];
|
|
|
|
$this->environmentName = $parameters['environment_name'];
|
2023-05-22 12:47:15 +02:00
|
|
|
}
|
2023-08-08 11:51:36 +02:00
|
|
|
|
2023-05-22 12:47:15 +02:00
|
|
|
public function delete()
|
|
|
|
{
|
2023-09-22 11:23:49 +02:00
|
|
|
try {
|
2023-12-13 15:34:33 +01:00
|
|
|
DeleteResourceJob::dispatch($this->resource);
|
2023-12-07 22:56:55 +01:00
|
|
|
return $this->redirectRoute('project.resources', [
|
2023-12-11 09:41:31 +01:00
|
|
|
'project_uuid' => $this->projectUuid,
|
|
|
|
'environment_name' => $this->environmentName
|
2023-12-07 22:56:55 +01:00
|
|
|
], navigate: true);
|
2023-09-22 11:23:49 +02:00
|
|
|
} catch (\Throwable $e) {
|
2023-09-22 14:47:25 +02:00
|
|
|
return handleError($e, $this);
|
2023-09-22 11:23:49 +02:00
|
|
|
}
|
2023-05-22 12:47:15 +02:00
|
|
|
}
|
2023-05-18 13:26:35 +02:00
|
|
|
}
|