Skip to content

Instantly share code, notes, and snippets.

@vinicius73
Last active August 29, 2015 14:22
Show Gist options
  • Save vinicius73/2a06136f334ff4643056 to your computer and use it in GitHub Desktop.
Save vinicius73/2a06136f334ff4643056 to your computer and use it in GitHub Desktop.
DatabaseSeeder.php final
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use DB;
class DatabaseSeeder extends Seeder {
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
// Desabilitas as FKs
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
$this->call('DefenderSeeder');
// Impede que seed seja executado em ambiente de produção
if(!app()->environment('production')):
$this->call('UserTableSeeder');
endif;
if(app()->environment('production')):
// seeds especiais para o ambiente de produção
endif;
if(app()->environment('testing')):
// seeds especiais para o ambiente de testes
endif;
// by Codecasts
// Habilitas as FKs
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