HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/zipwire.komma.pro/app/KommaApp/Kms/ActionLog/ActionLogger.php
<?php


namespace App\KommaApp\Kms\ActionLog;


use App\KommaApp\Users\Models\User;

class ActionLogger
{
    /**
     * Log an action to the database
     *
     *
     * @param string $actionText
     * @param null $payLoad Example: "['route' => '/login']". Don't make it to big!
     * @param User|null $user The user or null for the authenticated user / anonymous
     * @return ActionLog
     */
    public static function Log(string $actionText, $payLoad = null, User $user = null):ActionLog
    {
        if(!$user) if(\Auth::user()) $user = \Auth::user();

        $action = new ActionLog();
        $action->User()->associate($user);
        $action->action = $actionText;
        if($payLoad) $action->payload = $payLoad;

        $action->save();
        return $action;
    }
}