mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-22 19:22:19 +00:00
24 lines
515 B
PHP
24 lines
515 B
PHP
<?php
|
|
|
|
namespace App\Actions\SshKey;
|
|
|
|
use App\Enums\SshKeyStatus;
|
|
use App\Exceptions\SSHError;
|
|
use App\Models\Server;
|
|
use App\Models\SshKey;
|
|
|
|
class DeleteKeyFromServer
|
|
{
|
|
/**
|
|
* @throws SSHError
|
|
*/
|
|
public function delete(Server $server, SshKey $sshKey): void
|
|
{
|
|
$sshKey->servers()->updateExistingPivot($server->id, [
|
|
'status' => SshKeyStatus::DELETING,
|
|
]);
|
|
$server->os()->deleteSSHKey($sshKey->public_key);
|
|
$server->sshKeys()->detach($sshKey);
|
|
}
|
|
}
|