Files
services_core/app/Models/Invoice.php
T
2026-07-31 13:57:11 +07:00

70 lines
1.5 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Invoice extends Model
{
use SoftDeletes;
protected $guarded = ['id'];
protected function casts(): array
{
return [
'period_start' => 'date',
'period_end' => 'date',
'issue_date' => 'date',
'send_date' => 'date',
'warning_date' => 'date',
'isolation_date' => 'date',
'subtotal' => 'decimal:2',
'tax_rate' => 'decimal:2',
'tax_amount' => 'decimal:2',
'total' => 'decimal:2',
'paid_amount' => 'decimal:2',
'balance' => 'decimal:2',
'paid_at' => 'datetime',
'profile_snapshot' => 'array',
'metadata' => 'array',
];
}
public function tenant()
{
return $this->belongsTo(Tenant::class);
}
public function customer()
{
return $this->belongsTo(Customer::class);
}
public function billingProfile()
{
return $this->belongsTo(BillingProfile::class);
}
public function creator()
{
return $this->belongsTo(User::class, 'created_by');
}
public function updater()
{
return $this->belongsTo(User::class, 'updated_by');
}
public function payer()
{
return $this->belongsTo(User::class, 'paid_by');
}
public function paymentTransactions()
{
return $this->hasMany(PaymentTransaction::class);
}
}