@php // Formateadores $fmt = fn($n) => number_format((float)$n, 2, '.', ','); // bonito //$fmtRaw = fn($n) => (string) (int) round((float)$n); // crudo $fmtRaw = fn($n) => number_format((float)$n, 2, '.', ''); // en vez de (string)(int) round(...) $print = !empty($raw) ? $fmtRaw : $fmt; // Helper para pintar una lĂ­nea "En stock / En cero / Todos" $row = function(string $label, $value) use ($print) { return << {$label} {$print($value)} HTML; }; @endphp
@if(!empty($title))
{{ $title }}
@endif
@foreach($cards as $card)
{{ $card['label'] }}
{{-- Bloque USD (si existe) --}} @if(!is_null($card['usd'] ?? null))
USD Valores
{!! $row('En stock', $card['usd']['stock'] ?? 0) !!} {!! $row('En cero', $card['usd']['zero'] ?? 0) !!}
{!! $row('Todos', $card['usd']['all'] ?? 0) !!}
@endif {{-- Bloque PRIMARIA --}}
{{ $primaryCode ?? 'PRIM' }} Valores
{!! $row('En stock', $card['primary']['stock'] ?? 0) !!} {!! $row('En cero', $card['primary']['zero'] ?? 0) !!}
{!! $row('Todos', $card['primary']['all'] ?? 0) !!}
@endforeach