<?php

namespace App\EventHooks\Client;

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

/**
 * Fire noktası: ClientObserver::updated, status 'inactive'e geçince →
 * buildClientContext. Context: client (model), userid/user_id/client_id, status.
 */
class ClientClosed extends HookEvent
{
    public const HOOK = 'ClientClose';

    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;
    }
}
