{{-- Sous-menu horizontal de l'événement courant (affiché en haut du contenu) --}} @php $currentEventId = null; $currentEvent = null; if (request()->segment(1) === 'events' && is_numeric(request()->segment(2))) { $currentEventId = (int) request()->segment(2); $currentEvent = App\Models\Event::with('workshops', 'shows')->find($currentEventId); } @endphp @if ($currentEvent) @php $eventId = $currentEvent->id; $hasAdhesionBoPage = $currentEvent->has_adhesion_bo_page; $hasCateringBoPage = $currentEvent->has_catering_bo_page; $hasSessions = $currentEvent->workshops->where('f3', 'session')->count() > 0 || $currentEvent->workshops->where('f3', 'atelier')->count() > 0; $currentPage = request()->segment(3); // ── Consolidated badge counts (single query per table) ── $participantCounts = DB::table('participants') ->where('event_id', $eventId) ->selectRaw('COUNT(*) as total') ->selectRaw("SUM(code != '' AND code IS NOT NULL) as confirmed") ->selectRaw("SUM(code != '' AND code IS NOT NULL AND is_present = '1') as present") ->selectRaw("SUM(code != '' AND code IS NOT NULL AND category = 'Prise en charge') as pec") ->first(); $abstractCounts = null; if ($currentEvent->has_abstracts) { $abstractCounts = DB::table('abstracts') ->where('event_id', $eventId) ->selectRaw('COUNT(*) as total') ->selectRaw("SUM(review = 'Approuver') as approved") ->first(); } $roomCounts = null; $reservationCounts = null; if ($currentEvent->has_hebergement_bo) { $roomCounts = DB::table('room_reservations') ->where('event_id', $eventId) ->selectRaw('COUNT(*) as total') ->selectRaw("SUM(code != '' AND code IS NOT NULL) as with_code") ->selectRaw("SUM(code != '' AND code IS NOT NULL AND is_checked = 1) as checked") ->first(); $reservationCounts = DB::table('reservations') ->where('event_id', $eventId) ->selectRaw('COUNT(*) as total') ->selectRaw("SUM(status = 'validated') as validated") ->selectRaw("SUM(status = 'pending') as pending") ->first(); } $evaluationCount = null; if ($currentEvent->has_evaluation) { $evaluationCount = DB::table('answers') ->where('event_id', $eventId) ->distinct('created_at') ->count('created_at'); } @endphp
@endif