47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Observers\DelayedGoodObserver;
|
|
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
#[ObservedBy([DelayedGoodObserver::class])]
|
|
class DelayedGood extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'stored_date' => 'date',
|
|
'payment_date' => 'date',
|
|
'quantity' => 'decimal:2',
|
|
'unit_price' => 'integer',
|
|
'total_amount' => 'integer',
|
|
'paid_amount' => 'integer',
|
|
'is_paid' => 'boolean',
|
|
];
|
|
}
|
|
|
|
public function customer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Customer::class);
|
|
}
|
|
|
|
public function unit(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Unit::class);
|
|
}
|
|
|
|
public function warehouse(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Warehouse::class);
|
|
}
|
|
}
|