mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-19 01:41:36 +00:00
29 lines
720 B
PHP
29 lines
720 B
PHP
<?php
|
|
|
|
namespace App\Actions\Service;
|
|
|
|
use App\Enums\ServiceStatus;
|
|
use App\Models\Service;
|
|
use Illuminate\Support\Facades\Validator;
|
|
|
|
class Uninstall
|
|
{
|
|
public function uninstall(Service $service): void
|
|
{
|
|
Validator::make([
|
|
'service' => $service->id,
|
|
], $service->handler()->deletionRules())->validate();
|
|
|
|
$service->status = ServiceStatus::UNINSTALLING;
|
|
$service->save();
|
|
|
|
dispatch(function () use ($service) {
|
|
$service->handler()->uninstall();
|
|
$service->delete();
|
|
})->catch(function () use ($service) {
|
|
$service->status = ServiceStatus::FAILED;
|
|
$service->save();
|
|
})->onConnection('ssh');
|
|
}
|
|
}
|