<?php

declare(strict_types=1);

namespace App\Listeners;

use App\Models\ActivityLogNamesEnum;
use Illuminate\Contracts\Queue\ShouldQueue;
use Seka\Vzdelavanie\Events\Testovanie\Frontend\TestGenerated;

/**
 * Class AktivitaVzdelavanieTestovanieGenerovanieTestuPouzivatelom
 */
final class AktivitaVzdelavanieTestovanieGenerovanieTestuPouzivatelom implements ShouldQueue
{
    public function handle(TestGenerated $event): void
    {
        activity()
            ->by($event->pouzivatel)
            ->inLog(ActivityLogNamesEnum::VZDELAVANIE_TESTY->value)
            ->performedOn($event->test)
            ->withProperties([
                'nazov' => $event->test->nazov,
                'request' => [
                    'ip' => $event->request->get('REMOTE_ADDR'),
                    'user_agent' => $event->request->get('user-agent'),
                ],
            ])
            ->log(get_class($event));
    }
}
