<?php

namespace App\EventHooks\Domain;

use App\EventHooks\HookEvent;
use App\Models\ClientDomain;

/**
 * Fire noktası: DomainObserver::updated → DomainEdit (buildDomainContext).
 * Context: domain (ClientDomain modeli), domain_id/domainid, client_id/user_id, status.
 */
class DomainEdited extends HookEvent
{
    public const HOOK = 'DomainEdit';

    public function domain(): ?ClientDomain
    {
        $d = $this->get('domain');
        if ($d instanceof ClientDomain) {
            return $d;
        }
        $id = $this->get('domain_id') ?? $this->get('domainid');

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