<?php

namespace App\Domains\Purchase\Models;

use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

#[Fillable([
    'compra_id',
    'matched_purchase_ids',
    'cuit_buyer',
    'cvu_buyer',
    'amount',
    'concept',
    'operation',
    'operation_id',
    'transaction_id',
    'qr_order_id',
    'link_id',
])]
class TelepagosPayment extends Model
{
    use HasFactory;

    protected $table = 'telepagos_payments';

    protected function casts(): array
    {
        return [
            'compra_id' => 'integer',
            'matched_purchase_ids' => 'array',
            'amount' => 'decimal:2',
        ];
    }

    /**
     * @return BelongsTo<Purchase, $this>
     */
    public function compra(): BelongsTo
    {
        return $this->belongsTo(Purchase::class, 'compra_id');
    }
}
