<?php

namespace App\EventHooks\Client;

use App\EventHooks\HookEvent;
use App\Models\User;

/**
 * Fire noktası: UserObserver::updated → buildUserContext + ['olddata' => original].
 * Context: user (model), userid/user_id, olddata.
 */
class UserEdited extends HookEvent
{
    public const HOOK = 'UserEdit';

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

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