sshKeys()->attach($sshKey, [ 'status' => SshKeyStatus::ADDING, ]); $server->os()->deploySSHKey($sshKey->public_key); $sshKey->servers()->updateExistingPivot($server->id, [ 'status' => SshKeyStatus::ADDED, ]); } }