<?php

declare(strict_types=1);

namespace Seka\Vzdelavanie\Events\Kniznica;

use Illuminate\Support\Facades\App;
use Illuminate\Contracts\Auth\Authenticatable;
use Symfony\Component\HttpFoundation\ParameterBag;

/**
 * Trait ActivityLogTrait
 *
 * @package Seka\Vzdelavanie\Events\Kniznica
 */
trait ActivityLogTrait
{
    /**
     * @var \Symfony\Component\HttpFoundation\ParameterBag|null
     */
    public ?ParameterBag $request;

    /**
     * @var \Illuminate\Contracts\Auth\Authenticatable|null
     */
    public ?Authenticatable $pouzivatel;

    /**
     * ActivityLogTrait constructor.
     */
    protected function setActivityLogParameters()
    {
        $this->pouzivatel = auth()->user();
        $this->request = App::runningInConsole() ? null : new ParameterBag(array_merge(request()->server->all(), request()->headers->all()));
    }
}
