phpvms/app/Database/seeds/DatabaseSeeder.php

37 lines
839 B
PHP
Raw Normal View History

2017-06-09 02:28:26 +08:00
<?php
use App\Services\Installer\MigrationService;
use App\Services\Installer\SeederService;
2017-06-09 02:28:26 +08:00
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder
{
/** @var MigrationService */
private $migrationSvc;
/** @var SeederService */
private $seederSvc;
public function __construct()
{
$this->migrationSvc = app(MigrationService::class);
$this->seederSvc = app(SeederService::class);
}
2017-06-09 02:28:26 +08:00
/**
* Run the database seeds.
2018-08-27 00:40:04 +08:00
*
* @throws Exception
2017-06-09 02:28:26 +08:00
*/
public function run()
{
// Make sure any migrations that need to be run are run/cleared out
if ($this->migrationSvc->migrationsAvailable()) {
$this->migrationSvc->runAllMigrations();
}
// Then sync all of the seeds
$this->seederSvc->syncAllSeeds();
}
2017-06-09 02:28:26 +08:00
}