Aktuelle Touren im Jahres-Pillen-Layout
This commit is contained in:
parent
b52155c5f0
commit
183422b0c8
2 changed files with 75 additions and 16 deletions
|
|
@ -17,14 +17,46 @@ class TourController
|
|||
{
|
||||
$tours = Tour::upcoming();
|
||||
$participantCount = [];
|
||||
$toursByYear = [];
|
||||
|
||||
foreach ($tours as $tour) {
|
||||
$participantCount[$tour->id] = Booking::countForTour((int) $tour->id);
|
||||
|
||||
// Jahr vor der Formatierung aus dem DB-Datum (YYYY-MM-DD) lesen.
|
||||
$year = (int) substr((string) $tour->start, 0, 4);
|
||||
if ($year < 1900) {
|
||||
$year = 0;
|
||||
}
|
||||
|
||||
$tour->start = german_date($tour->start);
|
||||
$tour->deadline = german_date($tour->deadline);
|
||||
|
||||
$toursByYear[$year][] = $tour;
|
||||
}
|
||||
|
||||
view('tour.index', ['tours' => $tours, 'participantCount' => $participantCount]);
|
||||
krsort($toursByYear, SORT_NUMERIC);
|
||||
$years = array_keys($toursByYear);
|
||||
|
||||
// Ohne Auswahl werden alle Jahre gruppiert angezeigt. ?jahr=2026 filtert.
|
||||
$requestedYear = input('jahr');
|
||||
$selectedYear = null;
|
||||
|
||||
if (is_string($requestedYear) && ctype_digit($requestedYear)) {
|
||||
$candidate = (int) $requestedYear;
|
||||
if (isset($toursByYear[$candidate])) {
|
||||
$selectedYear = $candidate;
|
||||
}
|
||||
}
|
||||
|
||||
$visibleYears = $selectedYear === null ? $years : [$selectedYear];
|
||||
|
||||
view('tour.index', [
|
||||
'toursByYear' => $toursByYear,
|
||||
'years' => $years,
|
||||
'visibleYears' => $visibleYears,
|
||||
'selectedYear' => $selectedYear,
|
||||
'participantCount' => $participantCount,
|
||||
]);
|
||||
}
|
||||
|
||||
public function indexOld(): void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue