52 lines
1.2 KiB
PHP
52 lines
1.2 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',
|
|
'pdf_path',
|
|
'linked_invoice_id',
|
|
'approved_at',
|
|
'total_sem_amount',
|
|
'total_net_amount',
|
|
];
|
|
|
|
protected $casts = [
|
|
'approved_at' => 'datetime',
|
|
'total_sem_amount' => 'decimal:6',
|
|
'total_net_amount' => 'decimal:6',
|
|
];
|
|
|
|
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');
|
|
}
|
|
|
|
public function payments(): HasMany
|
|
{
|
|
return $this->hasMany(ClientInvoicePayment::class, 'client_invoice_id');
|
|
}
|
|
}
|