$value) { $key = ($key === 'daemonSFTP') ? 'daemonSftp' : $key; $normalized[Str::snake($key)] = $value; } return $normalized; } /** * @return list */ public function after(): array { return [function (Validator $validator): void { if ($this->isSecure() && $this->input('scheme') === 'http') { $validator->errors()->add( 'scheme', 'HTTP node connections cannot be used when the Panel is loaded over HTTPS.' ); } }]; } /** Rename fields to be more clear in error messages. */ public function attributes(): array { return [ 'daemon_base' => 'Daemon Base Path', 'upload_size' => 'File Upload Size Limit', 'location_id' => 'Location', 'public' => 'Node Visibility', ]; } /** * Remap snake_case keys back to the daemon* keys the services expect. * * @return NodeCreationData */ public function payload(): array { $data = parent::validated(); $daemonBase = Arr::get($data, 'daemon_base'); $response = [ 'name' => JsonValueGuard::string(Arr::get($data, 'name')), 'location_id' => JsonValueGuard::integer(Arr::get($data, 'location_id')), 'fqdn' => JsonValueGuard::string(Arr::get($data, 'fqdn')), 'scheme' => JsonValueGuard::string(Arr::get($data, 'scheme')), 'memory' => JsonValueGuard::integer(Arr::get($data, 'memory')), 'memory_overallocate' => JsonValueGuard::integer(Arr::get($data, 'memory_overallocate')), 'disk' => JsonValueGuard::integer(Arr::get($data, 'disk')), 'disk_overallocate' => JsonValueGuard::integer(Arr::get($data, 'disk_overallocate')), 'daemonListen' => JsonValueGuard::integer(Arr::get($data, 'daemon_listen')), 'daemonSFTP' => JsonValueGuard::integer(Arr::get($data, 'daemon_sftp')), 'daemonBase' => $daemonBase !== null && $daemonBase !== '' ? JsonValueGuard::string($daemonBase) : '/var/lib/pterodactyl/volumes', ]; if (array_key_exists('description', $data)) { $description = Arr::get($data, 'description'); $response['description'] = $description !== null && $description !== '' ? JsonValueGuard::string($description) : null; } foreach (['public', 'behind_proxy', 'maintenance_mode'] as $boolean) { if (array_key_exists($boolean, $data)) { $response[$boolean] = JsonValueGuard::boolean(Arr::get($data, $boolean)); } } $uploadSize = Arr::get($data, 'upload_size'); if ($uploadSize !== null && $uploadSize !== '') { $response['upload_size'] = JsonValueGuard::integer($uploadSize); } return $response; } }