<?php

namespace App\Listeners;

use App\Events\BadgeEarned;
use App\Services\Quiz\BadgeService;

class BadgeEarnedListener
{
    /**
     * Create the event listener.
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     */
    public function handle(BadgeEarned $event): void
    {
        $user = $event->user;
        try {
            $badge_service = new BadgeService;

            $badge_service->checkAndAssignBadges($user);

        } catch (\Throwable $th) {
        }
    }
}
