47 lines
1.0 KiB
PHP
47 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use App\Models\Inventory;
|
|
use App\Models\User;
|
|
|
|
class InventoryTransaction extends Model
|
|
{
|
|
/** @use HasFactory<\Database\Factories\InventoryTransactionFactory> */
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'inventory_id',
|
|
'type',
|
|
'quantity',
|
|
'balance_before',
|
|
'balance_after',
|
|
'reason',
|
|
'reference_type',
|
|
'reference_id',
|
|
'user_id',
|
|
'actual_time',
|
|
];
|
|
|
|
protected $casts = [
|
|
'actual_time' => 'datetime',
|
|
];
|
|
|
|
public function inventory(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(Inventory::class);
|
|
}
|
|
|
|
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
public function reference(): \Illuminate\Database\Eloquent\Relations\MorphTo
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
}
|