<?php

namespace App\EventHooks\Domain;

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

class DomainTransferCompleted extends HookEvent
{
    public const HOOK = 'DomainTransferCompleted';

    /**
     * Context'te 'domain' (ClientDomain modeli) ve 'domain_id' birlikte gelir
     * (bk. HookBridge::buildDomainContext); ikisini de destekle.
     */
    public function domain(): ?ClientDomain
    {
        $d = $this->get('domain');
        if ($d instanceof ClientDomain) {
            return $d;
        }
        $id = $this->get('domain_id') ?? (is_array($d) ? ($d['id'] ?? null) : null);

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

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