63 lines
1.4 KiB
PHP
63 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Koneko\VuexyWarehouse\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Koneko\VuexyStoreManager\Models\Store;
|
|
|
|
class LotNumber extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $table = 'lot_numbers';
|
|
protected $primaryKey = 'id';
|
|
public $incrementing = false;
|
|
protected $keyType = 'mediumint';
|
|
|
|
protected $fillable = [
|
|
'product_id',
|
|
'store_id',
|
|
'warehouse_id',
|
|
'lot_number',
|
|
'production_date',
|
|
'expiry_date',
|
|
'initial_quantity',
|
|
'remaining_quantity',
|
|
'cost',
|
|
];
|
|
|
|
protected $casts = [
|
|
'production_date' => 'date',
|
|
'expiry_date' => 'date',
|
|
'initial_quantity' => 'decimal:6',
|
|
'remaining_quantity' => 'decimal:6',
|
|
'cost' => 'decimal:2',
|
|
];
|
|
|
|
/**
|
|
* Relación con el producto.
|
|
*/
|
|
public function product(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Product::class, 'product_id');
|
|
}
|
|
|
|
/**
|
|
* Relación con la sucursal.
|
|
*/
|
|
public function store(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Store::class, 'store_id');
|
|
}
|
|
|
|
/**
|
|
* Relación con el almacén.
|
|
*/
|
|
public function warehouse(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Warehouse::class, 'warehouse_id');
|
|
}
|
|
}
|