user(); $query = Event::with(['team', 'participants']) ->withCount([ 'caterings as caterings_yes_count' => fn ($q) => $q->where('status', 'yes'), 'timekeepers as timekeepers_yes_count' => fn ($q) => $q->where('status', 'yes'), ]) ->published(); if (! $user->canAccessAdminPanel()) { $query->whereIn('team_id', $user->accessibleTeamIds()); } // Alle Events für den Kalender $calendarEvents = $query->orderBy('start_at')->get() ->map(fn (Event $e) => [ 'id' => $e->id, 'title' => $e->title, 'type' => $e->type->value, 'typeLabel' => $e->type->label(), 'date' => $e->start_at->format('Y-m-d'), 'time' => $e->start_at->format('H:i'), 'team' => $e->team->name, 'url' => route('events.show', $e), 'tl' => [ 'y' => $e->participants->where('status', ParticipantStatus::Yes)->count(), 'n' => $e->participants->where('status', ParticipantStatus::No)->count(), 'o' => $e->participants->where('status', ParticipantStatus::Unknown)->count(), ], 'minMet' => $e->minimumsStatus(), ]); return view('dashboard', compact('calendarEvents')); } }