@php $user = \Illuminate\Support\Facades\Auth::user(); $stabileIds = []; if ($user instanceof \App\Models\User) { $stabileIds = \App\Support\StabileContext::accessibleStabili($user) ->pluck('id') ->map(fn($value) => (int) $value) ->filter(fn(int $value) => $value > 0) ->values() ->all(); } $avvisiCount = 0; $urgenzeCount = 0; if ($stabileIds !== []) { $baseQuery = \App\Models\Ticket::query() ->whereIn('stabile_id', $stabileIds) ->whereIn('stato', ['Aperto', 'Preso in Carico', 'In Lavorazione']); $urgenzeCount = (clone $baseQuery)->where('priorita', 'Urgente')->count(); $avvisiCount = (clone $baseQuery)->where('priorita', '!=', 'Urgente')->count(); } @endphp