CAMBIOS: Creado un "ProductSeeder" Para la carga de productos del excel. Falta cargar los productos.
This commit is contained in:
@@ -62,7 +62,7 @@ class DatabaseSeeder extends Seeder
|
||||
|
||||
// Generar 50 productos aleatorios más
|
||||
Product::factory(50)->create();
|
||||
|
||||
|
||||
// Clientes y Turnos
|
||||
$client = Client::create([
|
||||
'name' => 'Juan Perez',
|
||||
@@ -77,5 +77,7 @@ class DatabaseSeeder extends Seeder
|
||||
'problem_description' => 'Service completo y ajuste de cambios',
|
||||
'status' => 'pending'
|
||||
]);
|
||||
|
||||
$this->call(ProductSeeder::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Product;
|
||||
|
||||
class ProductSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// Productos del Excel
|
||||
$products = [
|
||||
// 1. BICICLETAS
|
||||
[
|
||||
'name' => 'Bicicleta Venzo Loki R29',
|
||||
'sku' => 'BIC-VEN-001',
|
||||
'price' => 450000,
|
||||
'cost' => 300000,
|
||||
'stock_quantity' => 2,
|
||||
'min_stock_alert' => 1,
|
||||
'type' => 'bike', // bike, accessory, clothing, spare
|
||||
],
|
||||
[
|
||||
'name' => 'Cámara 29 Valvula Auto',
|
||||
'sku' => 'CAM-29-A',
|
||||
'price' => 5000,
|
||||
'cost' => 2500,
|
||||
'stock_quantity' => 50,
|
||||
'min_stock_alert' => 10,
|
||||
'type' => 'accessory',
|
||||
],
|
||||
[
|
||||
'name' => 'Servicio de Lavado',
|
||||
'sku' => 'SRV-LAV',
|
||||
'price' => 3000,
|
||||
'cost' => 0,
|
||||
'stock_quantity' => 999,
|
||||
'min_stock_alert' => 0,
|
||||
'type' => 'service',
|
||||
],
|
||||
];
|
||||
|
||||
// BUCLE DE CARGA
|
||||
foreach ($products as $item) {
|
||||
Product::updateOrCreate(
|
||||
['sku' => $item['sku']],
|
||||
[
|
||||
'name' => $item['name'],
|
||||
'price' => $item['price'],
|
||||
'cost' => $item['cost'] ?? 0,
|
||||
'stock_quantity' => $item['stock_quantity'] ?? 0,
|
||||
'min_stock_alert' => $item['min_stock_alert'] ?? 5,
|
||||
'type' => $item['type'] ?? 'accessory',
|
||||
'description' => $item['description'] ?? null,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user