Issue/329 refactor seeding (#337)

* Fix Contracts class names

* Refactoring of the file seeds so it's not a mess

* StyleCI fixes
This commit is contained in:
Nabeel S
2019-08-05 08:27:53 -04:00
committed by GitHub
parent d4c172e734
commit 9f3ba05880
47 changed files with 548 additions and 394 deletions
+7 -32
View File
@@ -1,19 +1,16 @@
<?php
use App\Services\DatabaseService;
use App\Services\Installer\SeederService;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
private static $seed_mapper = [
'local' => 'dev',
'qa' => 'dev',
'staging' => 'dev',
];
private $seederService;
private static $always_seed = [
'permissions',
];
public function __construct()
{
$this->seederService = app(SeederService::class);
}
/**
* Run the database seeds.
@@ -22,28 +19,6 @@ class DatabaseSeeder extends Seeder
*/
public function run()
{
$env = App::environment();
if (array_key_exists($env, self::$seed_mapper)) {
$env = self::$seed_mapper[$env];
}
Log::info('Seeding from environment '.$env);
$path = database_path('seeds/'.$env.'.yml');
if (!file_exists($path)) {
$path = database_path('seeds/prod.yml');
}
$svc = app(DatabaseService::class);
$svc->seed_from_yaml_file($path);
// Always seed/sync these
foreach (self::$always_seed as $file) {
Log::info('Importing '.$file);
$path = database_path('seeds/'.$file.'.yml');
if (file_exists($path)) {
$svc->seed_from_yaml_file($path);
}
}
$this->seederService->syncAllSeeds();
}
}