<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Vzdelavanie\Listeners\Testovanie;

use Illuminate\Contracts\Queue\ShouldQueue;
use Seka\Portal\Modul\Vzdelavanie\Enums\ActivityLogNamesEnum;
use Seka\Portal\Modul\Vzdelavanie\Events\Testovanie\Frontend\TestGenerated;

/**
 * Class AktivitaVzdelavanieTestovanieGenerovanieTestuPouzivatelom
 *
 * @package Seka\Portal\Modul\Vzdelavanie\Listeners\Testovanie
 */
final class AktivitaVzdelavanieTestovanieGenerovanieTestuPouzivatelom implements ShouldQueue
{
    public function handle(TestGenerated $event): void
    {
        activity()
            ->by($event->pouzivatel)
            ->inLog(ActivityLogNamesEnum::VZDELAVANIE_TESTY->name)
            ->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));
    }
}
