inspiren-sem-tool/app/Models/ClientInvoice.php

72 lines
1.8 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
class ClientInvoice extends Model
{
use HasFactory;
protected $fillable = [
'client_id',
'pending_sql_acc_code',
'pending_client_name',
'invoice_no',
'linked_invoice_id',
'is_credit_card',
'is_paid',
'approved_at',
'start_date',
'end_date',
'payment_no',
'amount',
'tax_percent',
'media_fee',
'media_fee_amount',
'media_fee_tax',
'management_fee',
'management_fee_amount',
'management_fee_tax',
'nett_amount',
'total_spending',
];
protected $casts = [
'start_date' => 'date',
'end_date' => 'date',
'is_credit_card' => 'boolean',
'is_paid' => 'boolean',
'approved_at' => 'datetime',
'amount' => 'decimal:2',
'tax_percent' => 'decimal:2',
'media_fee' => 'decimal:2',
'media_fee_amount' => 'decimal:2',
'media_fee_tax' => 'decimal:2',
'management_fee' => 'decimal:2',
'management_fee_amount' => 'decimal:2',
'management_fee_tax' => 'decimal:2',
'nett_amount' => 'decimal:2',
'total_spending' => 'decimal:2',
];
public function client(): BelongsTo
{
return $this->belongsTo(Client::class);
}
public function linkedInvoice(): BelongsTo
{
return $this->belongsTo(self::class, 'linked_invoice_id');
}
public function linkedInvoices(): HasMany
{
return $this->hasMany(self::class, 'linked_invoice_id');
}
}