2017-06-09 02:28:26 +08:00
|
|
|
<?php
|
|
|
|
|
2020-10-22 01:28:54 +08:00
|
|
|
use App\Services\Installer\MigrationService;
|
2019-08-05 20:27:53 +08:00
|
|
|
use App\Services\Installer\SeederService;
|
2017-06-09 02:28:26 +08:00
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
|
|
|
|
class DatabaseSeeder extends Seeder
|
|
|
|
{
|
2020-10-22 01:28:54 +08:00
|
|
|
/** @var MigrationService */
|
|
|
|
private $migrationSvc;
|
|
|
|
|
|
|
|
/** @var SeederService */
|
|
|
|
private $seederSvc;
|
2017-12-05 05:35:39 +08:00
|
|
|
|
2019-08-05 20:27:53 +08:00
|
|
|
public function __construct()
|
|
|
|
{
|
2020-10-22 01:28:54 +08:00
|
|
|
$this->migrationSvc = app(MigrationService::class);
|
|
|
|
$this->seederSvc = app(SeederService::class);
|
2019-08-05 20:27:53 +08:00
|
|
|
}
|
2019-06-21 04:52:37 +08:00
|
|
|
|
2017-06-09 02:28:26 +08:00
|
|
|
/**
|
|
|
|
* Run the database seeds.
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-03-31 11:28:19 +08:00
|
|
|
* @throws Exception
|
2017-06-09 02:28:26 +08:00
|
|
|
*/
|
|
|
|
public function run()
|
|
|
|
{
|
2020-10-22 01:28:54 +08:00
|
|
|
// 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-12 00:36:16 +08:00
|
|
|
}
|
2017-06-09 02:28:26 +08:00
|
|
|
}
|