adrema/app/Initialize/InitializeRegions.php

24 lines
618 B
PHP
Raw Normal View History

2020-04-12 00:26:44 +02:00
<?php
namespace App\Initialize;
class InitializeRegions {
private $bar;
private $api;
private $nullName = 'Nicht-DE (Ausland)';
public function __construct($bar, $api) {
$this->bar = $bar;
$this->api = $api;
}
public function handle() {
$this->bar->task('Synchronisiere Bundesländer', function() {
collect($this->api->regions()->data)->each(function($region) {
\App\Region::create(['nami_id' => $region->id, 'name' => $region->descriptor, 'is_null' => $region->descriptor === $this->nullName]);
});
});
}
}