62 خطوط
1.8 KiB
PHP
62 خطوط
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class Invoice extends Model
|
|
{
|
|
protected $fillable = [
|
|
'number', 'lead_id', 'invoice_template_id', 'created_by', 'approved_by',
|
|
'status', 'currency', 'customer_snapshot', 'seller_snapshot', 'lead_snapshot', 'items',
|
|
'resolved_fields', 'page_width_mm', 'page_height_mm', 'subtotal', 'discount', 'tax', 'total',
|
|
'paid_amount', 'payment_status', 'notes', 'payment_terms', 'due_date', 'issued_at', 'approved_at', 'rejected_at',
|
|
'rejection_reason', 'voided_at', 'version',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'customer_snapshot' => 'array',
|
|
'seller_snapshot' => 'array',
|
|
'lead_snapshot' => 'array',
|
|
'items' => 'array',
|
|
'resolved_fields' => 'array',
|
|
'page_width_mm' => 'integer',
|
|
'page_height_mm' => 'integer',
|
|
'subtotal' => 'decimal:2',
|
|
'discount' => 'decimal:2',
|
|
'tax' => 'decimal:2',
|
|
'total' => 'decimal:2',
|
|
'paid_amount' => 'decimal:2',
|
|
'due_date' => 'date',
|
|
'issued_at' => 'datetime',
|
|
'approved_at' => 'datetime',
|
|
'rejected_at' => 'datetime',
|
|
'voided_at' => 'datetime',
|
|
'version' => 'integer',
|
|
];
|
|
}
|
|
|
|
public function lead(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Lead::class);
|
|
}
|
|
|
|
public function template(): BelongsTo
|
|
{
|
|
return $this->belongsTo(InvoiceTemplate::class, 'invoice_template_id');
|
|
}
|
|
|
|
public function creator(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
}
|
|
|
|
public function approver(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'approved_by');
|
|
}
|
|
}
|