2020-04-12 00:26:44 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Initialize;
|
|
|
|
|
2022-02-12 16:16:56 +01:00
|
|
|
use Zoomyboy\LaravelNami\Api;
|
|
|
|
|
2020-04-12 00:26:44 +02:00
|
|
|
class InitializeRegions {
|
|
|
|
|
2022-02-12 16:16:56 +01:00
|
|
|
private Api $api;
|
|
|
|
private string $nullName = 'Nicht-DE';
|
2020-04-12 00:26:44 +02:00
|
|
|
|
2022-02-12 16:16:56 +01:00
|
|
|
public function __construct(Api $api) {
|
2020-04-12 00:26:44 +02:00
|
|
|
$this->api = $api;
|
|
|
|
}
|
|
|
|
|
2022-02-12 16:16:56 +01:00
|
|
|
public function handle(): void
|
|
|
|
{
|
2022-01-03 01:17:24 +01:00
|
|
|
$this->api->regions()->each(function($region) {
|
|
|
|
\App\Region::create(['nami_id' => $region->id, 'name' => $region->name, 'is_null' => $region->name == $this->nullName]);
|
2020-04-12 00:26:44 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|