adrema/app/Initialize/InitializeRegions.php

24 lines
580 B
PHP
Raw Normal View History

2020-04-12 00:26:44 +02:00
<?php
namespace App\Initialize;
class InitializeRegions {
private $bar;
private $api;
2021-04-10 00:55:43 +02:00
private $nullName = 'Nicht-DE';
2020-04-12 00:26:44 +02:00
public function __construct($bar, $api) {
$this->bar = $bar;
$this->api = $api;
}
public function handle() {
$this->bar->task('Synchronisiere Bundesländer', function() {
2021-04-10 00:55:43 +02: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
});
});
}
}