$source, 'label' => trim((string) ($definition['label'] ?? $source)) ?: $source, 'config' => $configKey, ]; } public function value(string $source, string $path, mixed $default = null): mixed { $definition = $this->definition($source); $suffix = trim($path, '.'); $key = $definition['config'] . ($suffix === '' ? '' : '.' . $suffix); $configured = config($key, $default); if ($this->usesLocalConfiguration()) { return $configured; } if ($suffix === 'connection') { return $this->connection($definition['key'], (array) $configured); } // Hosts and credentials come from the shared record, while the ODBC // driver must match the operating system that runs this application. if ($suffix === 'connection.odbc_driver' && trim((string) $configured) !== '') { return $configured; } return $this->storedConfiguration->value($definition['key'], $suffix, $configured); } public function enabled(string $source): bool { return (bool) $this->value($source, 'enabled', false); } private function usesLocalConfiguration(): bool { return (bool) config('upstreams.local_configuration.enabled', false); } private function connection(string $source, array $configured): array { $fields = array_values(array_unique(array_merge(array_keys($configured), [ 'host', 'port', 'database', 'username', 'password', 'odbc_driver', 'tds_version', 'connect_timeout', 'query_timeout', ]))); $resolved = $configured; foreach ($fields as $field) { $resolved[$field] = $this->value( $source, 'connection.' . $field, $configured[$field] ?? null, ); } return $resolved; } }