'required|string', 'description' => 'nullable|string', 'ip' => 'required', 'user' => 'required|string', 'port' => 'required|integer', 'is_swarm_manager' => 'required|boolean', ]; protected $validationAttributes = [ 'name' => 'Name', 'description' => 'Description', 'ip' => 'IP Address/Domain', 'user' => 'User', 'port' => 'Port', 'is_swarm_manager' => 'Swarm Manager', ]; public function mount() { $this->name = generate_random_name(); $this->private_key_id = $this->private_keys->first()->id; } public function setPrivateKey(string $private_key_id) { $this->private_key_id = $private_key_id; } public function instantSave() { $this->dispatch('success', 'Application settings updated!'); } public function submit() { $this->validate(); try { if (is_null($this->private_key_id)) { return $this->dispatch('error', 'You must select a private key'); } $server = Server::create([ 'name' => $this->name, 'description' => $this->description, 'ip' => $this->ip, 'user' => $this->user, 'port' => $this->port, 'team_id' => currentTeam()->id, 'private_key_id' => $this->private_key_id, 'proxy' => [ "type" => ProxyTypes::TRAEFIK_V2->value, "status" => ProxyStatus::EXITED->value, ], ]); $server->settings->is_swarm_manager = $this->is_swarm_manager; $server->settings->save(); $server->addInitialNetwork(); return redirect()->route('server.show', $server->uuid); } catch (\Throwable $e) { return handleError($e, $this); } } }