public function run() { $faker = Factory::create(); $orders = Order::lists('id'); $products = Product::sell()->lists('id'); foreach (range(1, 45) as $index) { if ($index > 29) { $index -= 29; } OrderProduct::create(['order_id' => $orders[$index], 'product_id' => $faker->randomElement($products), 'quantity' => $faker->numberBetween(1, 3)]); } }
public function run() { $faker = Faker::create(); $orderIds = Order::lists('id')->all(); foreach (range(1, 10) as $index) { OrderProduct::create(['order_id' => $faker->randomElement($orderIds), 'name' => $faker->word(), 'type' => $faker->numberBetween(0, 4), 'image_path' => $faker->word(), 'option_strength' => $faker->numberBetween(0, 4), 'option_milk' => $faker->numberBetween(0, 4), 'option_sugar' => $faker->numberBetween(0, 4), 'option_mug' => $faker->boolean()]); } }