@php $avg = $rating ?? 0; // fallback to 0 if null $avg = round($avg * 2) / 2; // round to nearest 0.5 @endphp