adrema/app/Initialize/Initializer.php

51 lines
1.1 KiB
PHP
Raw Normal View History

2022-01-03 01:17:24 +01:00
<?php
namespace App\Initialize;
2022-02-19 18:06:07 +01:00
use App\Setting\NamiSettings;
2022-01-03 01:17:24 +01:00
2022-03-11 20:19:17 +01:00
class Initializer
{
2022-02-19 18:06:07 +01:00
public NamiSettings $settings;
2022-08-31 00:34:20 +02:00
2022-09-02 00:45:39 +02:00
/**
* @var array<int, class-string>
*/
2022-02-19 18:06:07 +01:00
public array $initializers = [
2022-03-15 10:24:04 +01:00
InitializeGroups::class,
2022-01-03 01:17:24 +01:00
InitializeNationalities::class,
InitializeFees::class,
InitializeConfessions::class,
InitializeCountries::class,
InitializeGenders::class,
InitializeRegions::class,
InitializeCourses::class,
InitializeMembers::class,
];
2022-02-19 18:06:07 +01:00
public function __construct(NamiSettings $settings)
{
$this->settings = $settings;
}
2022-03-11 20:19:17 +01:00
public function run(): void
{
2022-02-19 18:06:07 +01:00
foreach ($this->initializers as $initializer) {
app($initializer)->handle($this->settings->login());
2022-01-03 01:17:24 +01:00
}
}
2022-09-02 00:45:39 +02:00
public function restore(): void
{
foreach (array_reverse($this->initializers) as $initializer) {
app($initializer)->restore();
}
$settings = app(NamiSettings::class);
$settings->mglnr = 0;
$settings->password = '';
$settings->default_group_id = 0;
$settings->save();
}
2022-01-03 01:17:24 +01:00
}