server = $server; $this->sshKey = $sshKey; } /** * @throws Throwable */ public function handle(): void { $this->server->ssh()->exec( new DeploySshKeyCommand($this->sshKey->public_key), 'deploy-ssh-key' ); $this->sshKey->servers()->updateExistingPivot($this->server->id, [ 'status' => SshKeyStatus::ADDED, ]); } public function failed(): void { $this->server->sshKeys()->detach($this->sshKey); } }