Add initial Code
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user