*/ class ProductFactory extends Factory { /** * Define the model's default state. * * @return array */ public function definition(): array { $brands = ['Shimano', 'Venzo', 'Trek', 'Specialized', 'Maxxis', 'Sram', 'Raleigh']; $bikeModels = ['Loki', 'Marlin 5', 'Chisel', 'Talon 3', 'Aspect 950']; $accessories = ['Guantes Grip', 'Calco Reflectora', 'Coderas', 'Rodilleras', 'Casco MTB', 'Luz Delantera USB', 'Cubierta Kevlar']; // PARA DESPUES $spareParts = ['Manubrio', 'Pedales Aluminio', 'Cámara 29"', 'Rayos x50', 'Disco de Freno', 'Cable de Freno', 'Asiento Goma', 'Cadena 9v']; $type = $this->faker->randomElement(['bike', 'accessory', 'service']); // Generar nombre según el tipo if ($type === 'bike') { $name = $this->faker->randomElement($brands) . ' ' . $this->faker->randomElement($bikeModels); } elseif ($type === 'accessory') { $name = $this->faker->randomElement($accessories) . ' ' . $this->faker->randomElement(['Pro', 'Basic', 'Comp', 'Elite']); } else { $name = $this->faker->randomElement(['Service General', 'Ajuste Cambios', 'Centrado de Rueda', 'Lavado y Engrase']); } // Lógica de Precios $price = $this->faker->numberBetween(5000, 800000); $cost = $price * $this->faker->randomFloat(2, 0.5, 0.7); return [ 'name' => $name, 'sku' => strtoupper($this->faker->bothify('???-#####')), 'description' => $this->faker->sentence(10), 'price' => $price, 'cost' => $cost, 'stock_quantity' => $type === 'service' ? 0 : $this->faker->numberBetween(0, 50), 'min_stock_alert' => $this->faker->numberBetween(2, 10), 'type' => $type, // Nro de serie si es bicicleta 'serial_number' => $type === 'bike' ? strtoupper($this->faker->bothify('##??##??')) : null, ]; } }