name = generateRandomName(); $this->private_keys = PrivateKey::where('team_id', session('currentTeam')->id)->get(); } public function setPrivateKey($private_key_id) { $this->private_key_id = $private_key_id; } public function submit() { if (!$this->private_key_id) { $this->addError('private_key_id', 'The private key field is required.'); return; } $server = Server::create([ 'name' => $this->name, 'description' => $this->description, 'ip' => $this->ip, 'user' => $this->user, 'port' => $this->port, 'team_id' => session('currentTeam')->id, 'private_key_id' => $this->private_key_id ]); return redirect()->route('server.show', $server->uuid); } }