40 lines
905 B
PHP
40 lines
905 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Guarded;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
#[Guarded(['id'])]
|
|
class RetailStockHistory extends Model
|
|
{
|
|
protected $table = 'retail_stock_histories';
|
|
|
|
public $timestamps = false;
|
|
|
|
// 1. Casting
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'created_at' => 'datetime',
|
|
'quantity' => 'integer',
|
|
'stock_after' => 'integer',
|
|
'stock_before' => 'integer',
|
|
'retail_stock_after' => 'integer',
|
|
'retail_stock_before' => 'integer',
|
|
];
|
|
}
|
|
|
|
// 2. Relation
|
|
public function productVariant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(ProductVariant::class);
|
|
}
|
|
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
}
|