<?php

namespace App\EventHooks\Client;

use App\EventHooks\HookEvent;
use App\Models\Client;

/**
 * Fire noktası: ClientObserver::updated → buildClientContext + ['olddata' => original].
 * Context: client (model), userid/user_id/client_id, olddata.
 */
class ClientEdited extends HookEvent
{
    public const HOOK = 'ClientEdit';

    public function client(): ?Client
    {
        $c = $this->get('client');
        if ($c instanceof Client) {
            return $c;
        }
        $id = $this->get('client_id') ?? $this->get('user_id') ?? $this->get('userid');

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