<?php

namespace App\EventHooks\Invoice;

use App\EventHooks\HookEvent;
use App\Models\Transaction;

/**
 * Fire noktası: TransactionObserver::created → AddTransaction
 * Context: transaction (model), id, gateway, currency, amountin, amountout, fees, invoiceid...
 */
class TransactionAdded extends HookEvent
{
    public const HOOK = 'AddTransaction';

    public function transaction(): ?Transaction
    {
        $t = $this->get('transaction');
        if ($t instanceof Transaction) {
            return $t;
        }
        $id = $this->get('transaction_id') ?? $this->get('id');

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