Last active
August 29, 2015 14:22
-
-
Save vinicius73/2a06136f334ff4643056 to your computer and use it in GitHub Desktop.
DatabaseSeeder.php final
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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