diff --git a/public/index.php b/public/index.php
index 1c1b7b9..7fef304 100644
--- a/public/index.php
+++ b/public/index.php
@@ -7,6 +7,7 @@ use App\Core\Database;
use App\Models\Game;
use App\Models\Tipp;
use App\Models\Round;
+use App\Models\Season;
$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
@@ -20,8 +21,14 @@ if ($uri === '/' || $uri === '/index.php') {
echo "
Datenbank verbunden! Aktuell $userCount User im System.
";
echo "Rundenübersicht
";
- // ToDo: Saison-Logik implementieren. Aktuell werden alle Runden angezeigt.
- $rounds = $db->query("SELECT * FROM rounds ORDER BY id ASC")->fetchAll(PDO::FETCH_ASSOC);
+ $currentSeason = Season::getCurrent();
+
+ if ($currentSeason) {
+ echo "Saison: " . htmlspecialchars($currentSeason['name']) . "
";
+ $rounds = Round::getBySeason($currentSeason['id']);
+ } else {
+ $rounds = [];
+ }
if ($rounds) {
echo "";
foreach ($rounds as $round) {
diff --git a/src/Models/Season.php b/src/Models/Season.php
new file mode 100644
index 0000000..617860d
--- /dev/null
+++ b/src/Models/Season.php
@@ -0,0 +1,31 @@
+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();
+ }
+}