<?php

namespace App\EventHooks\Domain;

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

/**
 * PRC-648 — Domain renewal alert (reminder tier) gönderildi.
 * Fire: domain renewal reminder dispatch (fireAction).
 */
class DomainRenewalAlertSent extends HookEvent
{
    public const HOOK = 'DomainRenewalAlertSent';

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

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

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

    public function daysRemaining(): ?int
    {
        $v = $this->get('days_remaining');

        return $v !== null ? (int) $v : null;
    }
}
