public function run() { // Uncomment the below to wipe the table clean before populating DB::table('products_globex')->delete(); $faker = $this->getFaker(); $categories = App\Category::allLeaves()->get(); $category_count = count($categories); for ($i = 0; $i < 200; $i++) { $product = App\Product::create(['title' => $faker->sentence(rand(1, 3)), 'price' => rand(5, 50000), 'description' => $faker->sentence(), 'brand' => $faker->company, 'category_id' => $categories[rand(0, $category_count - 1)]->id]); $product->images()->create(['url' => '/img/noImage.jpg']); $globex = App\Globex::create(['stock' => rand(0, 100), 'price_rule_id' => rand(1, 10)]); $globex->product()->save($product); } }
public function run() { // Uncomment the below to wipe the table clean before populating DB::table('products_ads')->delete(); $faker = $this->getFaker(); $categories = App\Category::allLeaves()->get(); $category_count = count($categories); for ($i = 0; $i < 100; $i++) { $product = App\Product::create(['category_id' => $categories[rand(0, $category_count - 1)]->id, 'title' => $faker->sentence(), 'description' => $faker->paragraph(), 'price' => rand(1, 50000), 'brand' => $faker->company]); $product->images()->create(['url' => '/img/noImage.jpg']); $ad = App\Advertisement::create(['customer_id' => rand(1, 100), 'name' => $faker->name, 'pin' => $faker->postcode, 'address' => $faker->address, 'emirate_id' => rand(1, 7), 'phone' => $faker->phoneNumber]); $ad->product()->save($product); } }