feat: Implementiere Saison-Logik zur Anzeige aktueller Runden

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
torsten 2026-10-03 16:49:52 +02:00
parent 6a2e8cbb57
commit 7c71a00095
2 changed files with 40 additions and 2 deletions

31
src/Models/Season.php Normal file
View file

@ -0,0 +1,31 @@
<?php
namespace App\Models;
use App\Core\Database;
class Season {
/**
* Holt die aktuell als "aktiv" markierte Saison.
* Annahme: Es gibt eine Spalte `is_current` (TINYINT) in der `seasons` Tabelle.
* Fallback: Die Saison mit der höchsten ID.
*/
public static function getCurrent() {
$db = Database::getConnection();
// Versuche zuerst, eine explizit als aktuell markierte Saison zu finden
$stmt = $db->prepare("SELECT * FROM seasons WHERE is_current = 1 LIMIT 1");
$stmt->execute();
$season = $stmt->fetch();
if ($season) {
return $season;
}
// Fallback: Wenn keine Saison als aktuell markiert ist, nimm die mit der höchsten ID
$stmt = $db->prepare("SELECT * FROM seasons ORDER BY id DESC LIMIT 1");
$stmt->execute();
return $stmt->fetch();
}
}