database/seeds/DatabaseSeeder.php
/**
     * Run the database seeds.
     *
     * @return void
     */
Run the database seeds.
@return void
Run the database seeds . @return void
public function run()
    {
        DB::statement('PRAGMA foreign_keys = OFF');
        Users::truncate();
        Post::truncate();
        Comment::truncate();
        factory(Users::class, 10)->create();
        factory(Post::class, 50)->create();
        factory(Comment::class, 100)->create();
        DB::statement('PRAGMA foreign_keys = ON');
    }
public function run ( ) { DB :: statement ( 'PRAGMA foreign_keys = OFF' ) ; Users :: truncate ( ) ; Post :: truncate ( ) ; Comment :: truncate ( ) ; factory ( Users :: class , 10 ) -> create ( ) ; factory ( Post :: class , 50 ) -> create ( ) ; factory ( Comment :: class , 100 ) -> create ( ) ; DB :: statement ( 'PRAGMA foreign_keys = ON' ) ; }
Run the database seeds.
Run the database seeds .
//$this->call(UserSeeder::class); // Disable foreign key checking because truncate() will fail //DB::statement('SET FOREIGN_KEY_CHECKS = 0'); // Enable it back //DB::statement('SET FOREIGN_KEY_CHECKS = 1');