update
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class InventarioPrenda extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'orden_produccion_id',
|
||||
'cantidad_terminada',
|
||||
'cantidad_disponible',
|
||||
'fecha_ingreso',
|
||||
'estado',
|
||||
];
|
||||
|
||||
public function ordenProduccion()
|
||||
{
|
||||
return $this->belongsTo(OrdenProduccion::class);
|
||||
}
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
static::creating(function ($inventario) {
|
||||
// Al ingresar al inventario, todo está disponible
|
||||
$inventario->cantidad_disponible = $inventario->cantidad_terminada;
|
||||
|
||||
// Estado automático inicial
|
||||
$inventario->estado = 'en_bodega';
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user