This repository has been archived on 2025-12-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
vollstock 8703e5ff40
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
Add initial Code
2025-10-20 08:57:51 +02:00

53 lines
1016 B
PHP

<?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;
}
}