middleware('active.account'); } public function index(RecognitionFilterRequest $request): View { $closedMonths = RecognitionService::closedMonths(); $selected = $this->selectedMonth((string) $request->validated('period'), $closedMonths); return view('user.recognitions.index', [ 'periods' => $closedMonths, 'selected' => $selected, 'recognitions' => $selected ? $this->recognitions->recognitions($selected['month'], $selected['year']) : null, 'live' => $this->recognitions->liveRankings((int) now()->month, (int) now()->year), ]); } /** * Nur abgeschlossene Monate sind wählbar; alles andere fällt auf den Vormonat zurück. * * @param array $closedMonths * @return array{month: int, year: int}|null */ private function selectedMonth(string $period, array $closedMonths): ?array { foreach ($closedMonths as $closedMonth) { if ($period === sprintf('%d-%02d', $closedMonth['year'], $closedMonth['month'])) { return $closedMonth; } } return $closedMonths[0] ?? null; } }