<?php

namespace App\Services\Quiz\Criteria;

use App\Enums\UserQuizStatusEnum;
use App\Models\User;

class QuizzesAttempted implements BadgeCriteriaInterface
{
    public function isMet(User $user, array $criteria): bool
    {
        $requiredAttempts = $criteria['value'] ?? 50;

        return $user->quizzes()
            ->where('status', UserQuizStatusEnum::COMPLETED)
            ->count() >= $requiredAttempts;
    }
}
