Skip to content

Instantly share code, notes, and snippets.

@zgabievi
Created August 13, 2017 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zgabievi/8df0d433e7b943e30529f96ee76468b8 to your computer and use it in GitHub Desktop.
Save zgabievi/8df0d433e7b943e30529f96ee76468b8 to your computer and use it in GitHub Desktop.
FOREIGN_KEY problem in DatabaseSeeder solved!
<?php
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Eloquent::unguard();
DB::statement('SET FOREIGN_KEY_CHECKS = 0;');
// $this->call(UsersTableSeeder::class);
DB::statement('SET FOREIGN_KEY_CHECKS = 1;');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment