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

34 lines
827 B
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;
2023-05-22 10:47:15 +00:00
public array $parameters;
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);
$this->parameters = get_route_parameters();
2023-05-22 10:47:15 +00:00
}
2023-05-22 10:47:15 +00:00
public function delete()
{
2023-09-22 09:23:49 +00:00
try {
DeleteResourceJob::dispatchSync($this->resource);
2023-12-07 21:56:55 +00:00
return $this->redirectRoute('project.resources', [
2023-09-22 09:23:49 +00:00
'project_uuid' => $this->parameters['project_uuid'],
'environment_name' => $this->parameters['environment_name']
2023-12-07 21:56:55 +00:00
], navigate: true);
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
}