<?php

declare(strict_types=1);

use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;

/** 
 * User function, returns user, if there is no user, returns empty User class
 */
function user(): User|null
{
    return Auth::user() ?? new User([
        'locale' => config('hr.default_locale'),
        'name' => 'Guest',
        'email' => 'guest@example.com',
        'password' => Hash::make('password'),
        'email_verified_at' => now(),
        'remember_token' => Str::random(10),
        'created_at' => now(),
        'updated_at' => now(),
    ]);
}