<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class InvoiceTransaction extends Model
{
    protected $fillable = [
        'support_invoice_id',
        'user_id',
        'transaction_id',
        'amount',
        'currency',
        'payment_method',
        'status',
        'stripe_payment_intent_id',
        'stripe_charge_id',
        'payment_method_details',
        'paid_at',
    ];

    protected $casts = [
        'amount' => 'decimal:2',
        'paid_at' => 'datetime',
        'payment_method_details' => 'array',
    ];

    public function invoice(): BelongsTo
    {
        return $this->belongsTo(SupportInvoice::class, 'support_invoice_id');
    }

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }
}
