public function run() { Vehicle::truncate(); $faker = Faker::create(); for ($i = 0; $i < 500; $i++) { Vehicle::create(['color' => $faker->safeColorName(), 'power' => $faker->randomNumber(), 'capacity' => $faker->randomFloat(), 'speed' => $faker->randomFloat(), 'maker_id' => $faker->numberBetween(1, 200)]); } }
/** * Run the database seeds. * * @return void */ public function run() { DB::statement('SET FOREIGN_KEY_CHECKS = 0'); Model::unguard(); Maker::truncate(); //delete the previous db data and then seed the db Vehicle::truncate(); $this->call('MakerTableSeeder'); $this->call('VehicleTableSeeder'); Model::reguard(); }
/** * Run the database seeds. * * @return void */ public function run() { DB::statement('SET FOREIGN_KEY_CHECKS=0'); Maker::truncate(); Vehicle::truncate(); User::truncate(); DB::statement('SET FOREIGN_KEY_CHECKS=1'); Model::unguard(); $this->call(MakerTableSeeder::class); $this->call(VehicleTableSeeder::class); $this->call(UserTableSeeder::class); Model::reguard(); }
/** * Run the database seeds. * * @return void */ public function run() { //disable foreign key check for this connection before running seeders DB::statement('SET FOREIGN_KEY_CHECKS=0;'); Vehicle::truncate(); Maker::truncate(); User::truncate(); Model::unguard(); $this->call('MakersSeed'); $this->call('VehiclesSeed'); $this->call('UsersSeed'); //might not be necessary DB::statement('SET FOREIGN_KEY_CHECKS=1;'); }