@php $alerts = $serviceDueAlerts ?? collect(); $overdueCount = (int) ($serviceDueOverdueCount ?? $alerts->where('status', 'overdue')->count()); $totalCount = (int) ($serviceDueCount ?? $alerts->count()); $soonCount = max(0, $totalCount - $overdueCount); $badgeCount = $overdueCount > 0 ? $overdueCount : $totalCount; @endphp