@php function getColor2($value) { return match (true) { $value >= 90 => '#10b981', // Green $value >= 70 => '#f59e0b', // Yellow default => '#ef4444', // Red }; } $metricsM = [ ['label' => 'Performance', 'value' =>$m['mobile_performance'] ?? 0], ['label' => 'Accessibility', 'value' =>$m['mobile_accessibility'] ?? 0], ['label' => 'Best Practices', 'value' => $m['mobile_best_practices'] ?? 0], ['label' => 'SEO', 'value' => $m['mobile_seo'] ?? 0], ]; foreach ($metricsM as &$metric) { $metric['color'] = getColor2($metric['value']); } unset($metric); // <- IMPORTANT! @endphp
Mobile Audit Report
@foreach($metricsM as $index => $metric)
{{ $metric['label'] }}
@endforeach