lasthourcloud/app/Http/Livewire/Project/Application/Danger.php

32 lines
921 B
PHP
Raw Normal View History

2023-05-18 11:26:35 +00:00
<?php
namespace App\Http\Livewire\Project\Application;
2023-05-22 10:47:15 +00:00
use App\Models\Application;
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-05-22 10:47:15 +00:00
public Application $application;
public array $parameters;
2023-07-13 11:16:24 +00:00
public string|null $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-06-15 07:15:41 +00:00
$this->parameters = getRouteParameters();
2023-05-22 10:47:15 +00:00
}
public function delete()
{
$destination = $this->application->destination->getMorphClass()::where('id', $this->application->destination->id)->first();
2023-05-24 13:25:08 +00:00
instant_remote_process(["docker rm -f {$this->application->uuid}"], $destination->server);
2023-05-22 10:47:15 +00:00
$this->application->delete();
return redirect()->route('project.resources', [
'project_uuid' => $this->parameters['project_uuid'],
'environment_name' => $this->parameters['environment_name']
]);
}
2023-05-18 11:26:35 +00:00
}