<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class MultibancoReference extends Model
{
protected $table = 'multibanco_references';
protected $fillable = [
'vcard_id',
'order_id',
'entity',
'reference',
'amount',
'status', // pending | paid | expired | cancelled
'expires_at',
'paid_at',
];
protected $casts = [
'amount' => 'float',
'expires_at' => 'datetime',
'paid_at' => 'datetime',
];
public function vcard(): BelongsTo
{
return $this->belongsTo(Vcard::class);
}
public function isExpired(): bool
{
return $this->expires_at && $this->expires_at->isPast();
}
public function isPaid(): bool
{
return $this->status === 'paid';
}
}
|