<?php

declare(strict_types=1);

namespace App\Listeners;

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

/**
 * Class AktivitaVzdelavanieTestovanieSpustenieTestuPouzivatelom
 */
final class AktivitaVzdelavanieTestovanieSpustenieTestuPouzivatelom implements ShouldQueue
{
    /**
     * @return void
     */
    public function handle(TestSpustenie $event)
    {
        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));
    }
}
