server = $server; $this->sshKey = $sshKey; } /** * @throws Throwable */ public function handle() { $this->server->ssh()->exec( new DeleteSshKeyCommand($this->sshKey->public_key), 'delete-ssh-key' ); $this->server->sshKeys()->detach($this->sshKey); event( new Broadcast('delete-ssh-key-finished', [ 'sshKey' => $this->sshKey, ]) ); } public function failed(): void { $this->server->sshKeys()->attach($this->sshKey); event( new Broadcast('delete-ssh-key-failed', [ 'sshKey' => $this->sshKey, ]) ); } }