feat: Aktiviere neue Saison nach Erstellung automatisch

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
torsten 2026-10-04 18:04:20 +02:00
parent f852da3570
commit d571121200
2 changed files with 9 additions and 4 deletions

View file

@ -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);

View file

@ -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();