You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.3 KiB
42 lines
1.3 KiB
<?php
|
|
|
|
namespace App\Domains\Finance\Models;
|
|
|
|
use App\Domains\Finance\Casts\MoneyCurrency;
|
|
use App\Domains\Finance\Enums\InvoiceStatus;
|
|
use App\Domains\Finance\Policies\InvoiceReportPolicy;
|
|
use BadMethodCallException;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Attributes\UsePolicy;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
#[Fillable([
|
|
'invoice_id',
|
|
'invoice_name',
|
|
'customer_id',
|
|
'customer_name',
|
|
'amount',
|
|
'paid_amount',
|
|
'issued_at',
|
|
'paid_at',
|
|
'status',
|
|
])]
|
|
#[UsePolicy(InvoiceReportPolicy::class)]
|
|
class InvoiceReport extends Model
|
|
{
|
|
public static function boot(): void
|
|
{
|
|
self::boot();
|
|
static::creating(fn (InvoiceReport $invoiceReport) => throw new BadMethodCallException('Cannot create invoice report from here, use event instead.'));
|
|
static::deleting(fn (InvoiceReport $invoiceReport) => throw new BadMethodCallException('Cannot delete invoice report.'));
|
|
static::updating(fn (InvoiceReport $invoiceReport) => throw new BadMethodCallException('Cannot update invoice report.'));
|
|
}
|
|
|
|
protected $casts = [
|
|
'amount' => MoneyCurrency::class,
|
|
'paid_amount' => MoneyCurrency::class,
|
|
'issued_at' => 'datetime',
|
|
'paid_at' => 'datetime',
|
|
'status' => InvoiceStatus::class,
|
|
];
|
|
}
|
|
|