From d5711212004df7510fa7c150d8174b604b512282 Mon Sep 17 00:00:00 2001 From: torsten Date: Sun, 4 Oct 2026 18:04:20 +0200 Subject: [PATCH] feat: Aktiviere neue Saison nach Erstellung automatisch Co-authored-by: aider (gemini/gemini-2.5-pro) --- public/index.php | 9 +++++++-- src/Models/Season.php | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/public/index.php b/public/index.php index f85b944..8cd5658 100644 --- a/public/index.php +++ b/public/index.php @@ -128,8 +128,13 @@ if ($page === 'login') { } if ($action === 'create') { - Season::create($data); - $_SESSION['admin_message'] = "Saison erfolgreich erstellt."; + $newSeasonId = Season::create($data); + if ($newSeasonId) { + Season::setCurrent($newSeasonId); + $_SESSION['admin_message'] = "Saison erfolgreich erstellt und als aktiv gesetzt."; + } else { + throw new \Exception("Saison konnte nicht erstellt werden."); + } } elseif ($seasonId) { Season::update($seasonId, $data); diff --git a/src/Models/Season.php b/src/Models/Season.php index aef415e..671621b 100644 --- a/src/Models/Season.php +++ b/src/Models/Season.php @@ -67,7 +67,7 @@ class Season { * Erstellt eine neue Saison und die zugehörigen Runden. * * @param array $data - * @return bool + * @return int|false Die ID der neuen Saison oder false bei einem Fehler. */ public static function create($data) { $db = Database::getConnection(); @@ -92,7 +92,7 @@ class Season { } $db->commit(); - return true; + return (int)$seasonId; } catch (\Exception $e) { $db->rollBack();