<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ImmigoProSubscription extends Model
{
    protected $table = 'immigo_pro_subscriptions';

    protected $fillable = [
        'user_id',
        'package_id',
        'package_name',
        'base_price',
        'payment_plan',
        'upfront_amount',
        'monthly_amount',
        'installments',
        'paid_installments',
        'total_amount',
        'tax_amount',
        'stripe_checkout_session_id',
        'stripe_payment_intent_id',
        'stripe_payment_method_id',
        'status',
        'next_charge_date',
        'completed_at',
        'billing_info',
    ];

    protected $casts = [
        'base_price' => 'decimal:2',
        'upfront_amount' => 'decimal:2',
        'monthly_amount' => 'decimal:2',
        'total_amount' => 'decimal:2',
        'tax_amount' => 'decimal:2',
        'next_charge_date' => 'datetime',
        'completed_at' => 'datetime',
    ];

    /**
     * Get the user that owns the subscription
     */
    public function user()
    {
        return $this->belongsTo(User::class);
    }

    /**
     * Get the package that this subscription is for
     */
    public function package()
    {
        return $this->belongsTo(ImmigoProPackage::class, 'package_id');
    }
}
