feat: Aktiviere neue Saison nach Erstellung automatisch
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
parent
f852da3570
commit
d571121200
2 changed files with 9 additions and 4 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue