<?php

declare(strict_types=1);

namespace App\Models\Subscription;

use Hyperf\DbConnection\Model\Model;
use App\Models\User;

class SubscriptionInvoice extends Model
{
    protected ?string $table = 'subscription_invoices';

    public bool $incrementing = true;

    protected array $fillable = [
        'hashkey',
        'subscription_id',
        'user_id',
        'amount',
        'status',
        'paid_at',
        'payment_method',
        'payment_reference',
        'additional_details',
        'created_by',
        'updated_by',
    ];

    protected array $casts = [
        'amount' => 'float',
        'paid_at' => 'datetime',
        'additional_details' => 'array',
    ];

    public function subscription()
    {
        return $this->belongsTo(Subscription::class, 'subscription_id');
    }

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