<?php

namespace App\Services\Quiz\Criteria;

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

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

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