<?php

namespace App\Services\Quiz\Criteria;

use App\Models\User;

class LeaderboardRank implements BadgeCriteriaInterface
{
    public function isMet(User $user, array $criteria): bool
    {
        $leaderboard = User::orderByDesc('score')->limit($criteria['value'] ?? 3)->pluck('id')->toArray();

        return in_array($user->id, $leaderboard);
    }
}
