Files

53 lines
1016 B
PHP
Raw Permalink Normal View History

2025-10-20 08:57:51 +02:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Models\Customer;
use App\Models\LineItem;
class Invoice extends Model
{
use HasFactory;
protected $fillable = [
'nr',
'invoice_date',
'due_date',
'service_start_date',
'service_end_date',
'is_recurring',
'is_partial_service',
'customer_id',
'billing_data',
'payment_status',
'total_amount',
'title',
'text',
'items'
];
protected $casts = [
'billing_data' => 'array', // JSON to Array
];
public function customer()
{
return $this->belongsTo(Customer::class);
}
public function items()
{
return $this->hasMany(LineItem::class);
}
/**
* Get the payment term for the invoice.
*/
public function getPaymentTermsAttribute()
{
return $this->customer->paymentTerms;
}
}