/** * Run the database seeds. * * @return void */ public function run() { //Truncate DB::statement('SET FOREIGN_KEY_CHECKS=0;'); User::truncate(); Admin::truncate(); Customer::truncate(); Address::truncate(); Category::truncate(); Product::truncate(); Brand::truncate(); Type::truncate(); Image::truncate(); DB::statement('TRUNCATE category_product;'); Product::clearIndices(); Product::reindex(); //Unguard Model::unguard(); //Call $this->call(UsersTableSeeder::class); $this->call(ProductsTableSeeder::class); //Reguard Model::reguard(); DB::statement('SET FOREIGN_KEY_CHECKS=1;'); }
public function run() { $faker = Faker\Factory::create(); DB::statement('SET FOREIGN_KEY_CHECKS = 0'); Product::truncate(); for ($i = 0; $i < 500; $i++) { $date = $faker->dateTimeThisYear($max = 'now'); Product::create(['name' => $faker->name, 'description' => $faker->realText($maxNbChars = 200, $indexSize = 2), 'url' => $faker->url, 'video_url' => $faker->url, 'image_url' => $faker->imageUrl(400, 400, 'fashion'), 'created_by' => rand(1, 10), 'category_id' => rand(1, 10), 'created_at' => $date->format('Y-m-d h:m:s'), 'updated_at' => $date->format('Y-m-d h:m:s'), 'created_at_date' => $date->format('Y-m-d')]); } DB::statement('SET FOREIGN_KEY_CHECKS = 1'); }
/** * Run the database seeds. * * @return void */ public function run() { Product::truncate(); factory(Product::class, 10)->create(); }