adrema/app/Initialize/InitializeGenders.php

24 lines
579 B
PHP
Raw Normal View History

2020-04-12 00:26:44 +02:00
<?php
namespace App\Initialize;
class InitializeGenders {
private $bar;
private $api;
2021-04-10 00:40:36 +02:00
public $nullName = 'Keine Angabe';
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 Geschlechter', function() {
2021-04-10 00:40:36 +02:00
$this->api->genders()->each(function($gender) {
\App\Gender::create(['nami_id' => $gender->id, 'name' => $gender->name, 'is_null' => $gender->name === $this->nullName]);
2020-04-12 00:26:44 +02:00
});
});
}
}