<?php

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\Request;

class LeaderboardController extends Controller
{
    public function index(Request $request)
    {
        $query = User::orderByDesc('elo')
            ->where('is_banned', false);

        if ($request->filled('division')) {
            $query->where('rank', $request->division);
        }

        $players = $query->paginate(20)->withQueryString();

        return view('leaderboard.index', compact('players'));
    }
}
