@php // Alíquotas salvas (decimais: ex. 0.18) $aliq = $sim->aliquotas->pluck('valor','chave'); $pct = fn($k) => number_format(($aliq[$k] ?? 0)*100, 2, ',', '.'); // 0.18 => "18,00" // helper para preencher com o que já foi lançado $rx = function (string $cat, string $tipo) use ($sim) { return $sim->receitas->where('categoria',$cat)->where('tipo',$tipo)->sum('valor'); }; @endphp