<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Tournament;

class TournamentController extends Controller
{
    public function index()
    {
        $tournaments = Tournament::withCount('participants')
            ->orderByDesc('created_at')
            ->get(['id', 'title', 'status', 'prize', 'max_players', 'starts_at', 'registration_closes_at']);

        return response()->json($tournaments);
    }
}
