@foreach($answers as $key => $value) @php $field = $definition['fields'][$key] ?? []; $empty = $value === null || $value === '' || $value === []; $display = $empty ? 'Não informado' : (is_bool($value) ? ($value ? 'Sim' : 'Não') : (is_scalar($value) ? ($field['options'][(string) $value] ?? (string) $value) : json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))); if (!$empty && ($field['type'] ?? null) === 'multiselect' && is_array($value)) { $display = implode(' · ', array_map(fn ($code) => $field['options'][$code] ?? $code, $value)); } if (!$empty && ($field['type'] ?? null) === 'consent') { $display = ['accepted' => 'Aceite', 'declined' => 'Recusado'][$value] ?? 'Resposta conservada sem classificação'; } if (!$empty && ($field['type'] ?? null) === 'attachment' && is_array($value)) { $display = implode(' · ', array_column($snapshot['field_attachments'][$key]['files'] ?? [], 'file_name')) ?: 'Selecção documental conservada; consulte o original técnico.'; } if (!$empty && in_array($key, ['investment_amount', 'own_finance', 'other_finance'], true) && is_numeric($value)) { $display = number_format((float)$value, 2, ',', ' ').' '.(($snapshot['payload']['currency'] ?? '') ?: '(moeda não informada)'); } @endphp