<?php

namespace App\EventHooks\Invoice;

use App\EventHooks\HookEvent;
use App\Models\Invoice;

/**
 * Fire noktası: InvoiceService overdue reminder fanout → InvoicePaymentReminder
 * Context: invoice_id, type, reminder_type, reminder_number. (invoice modeli taşınmaz; id'den lazy load.)
 */
class InvoicePaymentReminderSent extends HookEvent
{
    public const HOOK = 'InvoicePaymentReminder';

    public function invoice(): ?Invoice
    {
        $i = $this->get('invoice');
        if ($i instanceof Invoice) {
            return $i;
        }
        $id = $this->get('invoice_id');

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