find($this->session->get(static::SESSION_KEY)); return $yearPeriod !== null ? $yearPeriod : $this->current(); } public function current(): YearPeriod { return YearPeriod::current(); } public function links(): array { $selected = $this->selected(); $current = $this->current(); $years = YearPeriod::all(); $navigation = $years->map(fn(YearPeriod $yearPeriod): array => $this->toNavigation($yearPeriod)); return [ "current" => $this->toNavigation($current), "selected" => $this->toNavigation($selected), "navigation" => $navigation->toArray(), ]; } protected function toNavigation(YearPeriod $yearPeriod): array { return [ "year" => $yearPeriod->year, "link" => route("year-periods.select", $yearPeriod->id), ]; } }