<?php

namespace App\Models;

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

class AddonPurchase extends Model
{
    protected $fillable = [
        'user_id', 'addon_product_id', 'provider', 'provider_reference',
        'status', 'amount_paid', 'currency', 'meta',
    ];

    protected $casts = [
        'amount_paid' => 'decimal:2',
        'meta'        => 'array',
    ];

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

    public function product(): BelongsTo
    {
        return $this->belongsTo(AddonProduct::class, 'addon_product_id');
    }
}
