vito/app/Actions/SshKey/DeleteKeyFromServer.php
Saeed Vaziry 428140b931
refactoring (#116)
- refactoring architecture
- fix incomplete ssh logs
- code editor for scripts in the app
- remove Jobs and SSHCommands
2024-03-14 20:03:43 +01:00

20 lines
446 B
PHP

<?php
namespace App\Actions\SshKey;
use App\Enums\SshKeyStatus;
use App\Models\Server;
use App\Models\SshKey;
class DeleteKeyFromServer
{
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);
}
}