<?php

namespace App\EventHooks\Domain;

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

/**
 * Fire noktası: RegistrarManager::call() generic after-hook (updateDNSRecords →
 * suffix=SaveDNS → AfterRegistrarSaveDNS). Otomatik fire. Context: params
 * (domain=ad, domain_id, module_name), results, functionExists,
 * functionSuccessful. domain params'tan çözülür.
 */
class RegistrarDnsSaved extends HookEvent
{
    public const HOOK = 'AfterRegistrarSaveDNS';

    public function domain(): ?ClientDomain
    {
        $params = $this->get('params', []);
        $id = is_array($params) ? ($params['domain_id'] ?? null) : null;

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