ip
This commit is contained in:
@@ -97,6 +97,13 @@ class InventarioPrendaDistribucion extends Model
|
||||
$op = $dist->inventarioPrenda->ordenProduccion;
|
||||
$nombre = $op->prenda_modelo ?? $op->referencia ?? ('Producto OP #' . $op->id);
|
||||
|
||||
$codigo = 'AUTOD-' . $op->id . '-' . time();
|
||||
$codigo = substr($codigo, 0, 50);
|
||||
while (\App\Models\Producto::where('codigo_barras', $codigo)->exists()) {
|
||||
$codigo .= '-' . rand(0, 9);
|
||||
$codigo = substr($codigo, 0, 50);
|
||||
}
|
||||
|
||||
$producto = \App\Models\Producto::firstOrCreate(
|
||||
['nombre' => $nombre],
|
||||
[
|
||||
@@ -106,6 +113,7 @@ class InventarioPrendaDistribucion extends Model
|
||||
'precio_compra' => 0,
|
||||
'precio_venta' => 0,
|
||||
'unidad_medida' => 'unidad',
|
||||
'codigo_barras' => $codigo,
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user