<?php

namespace App\EventHooks\Client;

use App\EventHooks\HookEvent;
use App\Models\Admin;

/**
 * Fire noktası: AuthenticatedSessionController::destroy (admin guard logout).
 * Context: admin (model), userid/user_id, username. 'ipaddress' yok.
 * Admin guard provider App\Models\Admin'dir (App\Models\User DEĞİL).
 */
class AdminUserLoggedOut extends HookEvent
{
    public const HOOK = 'UserLogout';

    public function user(): ?Admin
    {
        $u = $this->get('admin');
        if ($u instanceof Admin) {
            return $u;
        }
        $id = $this->get('user_id') ?? $this->get('userid');

        return $id ? Admin::find($id) : null;
    }

    public function username(): ?string
    {
        return $this->get('username');
    }
}
