*/ public function toArray(Request $request): array { return [ 'codigo' => $this->websiteTypeExtra->codigo, 'nombre' => $this->websiteTypeExtra->nombre, 'descripcion' => $this->websiteTypeExtra->descripcion, 'is_required' => $this->websiteTypeExtra->is_required, 'is_enabled' => $this->is_enabled, 'request_rules' => $this->websiteTypeExtra->config_schema['request_rules'] ?? [], 'config' => $this->formatConfig( $this->resolvedConfig(), fn (Attachment $attachment): string => $attachment->key ), 'resolved_config' => $this->formatConfig( $this->resolvedConfig(), fn (Attachment $attachment): string => $attachment->getTemporaryUrl(1440) ), ]; } private function formatConfig(mixed $value, callable $formatAttachment): mixed { if ($value instanceof Attachment) { return $formatAttachment($value); } if (! is_array($value)) { return $value; } return array_map( fn (mixed $item): mixed => $this->formatConfig($item, $formatAttachment), $value ); } }