create([ 'user_id' => $server->user_id, 'name' => 'id_rsa', 'public_key' => 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDZ', ]); $server->sshKeys()->attach($sshKey, [ 'status' => SshKeyStatus::ADDED, ]); } } }