@props([ // Recibidos desde la clase: 'cards' => [], 'title' => 'Totales de inversión', 'raw' => false, 'primaryCode' => 'CUP', ]) @php $fmt = fn($n) => number_format((float)$n, 2, '.', ','); // bonito $fmtRaw = fn($n) => (string) (int) round((float)$n); // crudo $print = $raw ? $fmtRaw : $fmt; $chip = function(string $code) { return strtoupper($code) === 'USD' ? 'ml-1 px-1.5 py-0.5 rounded-md text-[10px] font-semibold bg-emerald-50 text-emerald-700 border border-emerald-200' : 'ml-1 px-1.5 py-0.5 rounded-md text-[10px] font-semibold bg-sky-50 text-sky-700 border border-sky-200'; }; @endphp
{{ $title }}
@foreach($cards as $card)
{{ $card['label'] }}
{{-- USD arriba si existe --}} @if(!is_null($card['usd']))
{{ $print($card['usd']) }} USD
@endif {{-- Moneda primaria debajo --}}
{{ $print($card['primary']) }} {{ $card['primary_code'] ?? $primaryCode }}
@endforeach