adrema/app/Initialize/InitializeGenders.php

25 lines
542 B
PHP
Raw Normal View History

2020-04-12 00:26:44 +02:00
<?php
namespace App\Initialize;
2021-11-17 23:58:28 +01:00
use Zoomyboy\LaravelNami\NamiUser;
2020-04-12 00:26:44 +02:00
class InitializeGenders {
private $bar;
private $api;
public function __construct($bar, $api) {
$this->bar = $bar;
$this->api = $api;
}
2021-11-17 23:58:28 +01:00
public function handle(NamiUser $user) {
2020-04-12 00:26:44 +02:00
$this->bar->task('Synchronisiere Geschlechter', function() {
2021-04-10 00:40:36 +02:00
$this->api->genders()->each(function($gender) {
2021-04-11 17:02:49 +02:00
\App\Gender::create(['nami_id' => $gender->id, 'name' => $gender->name]);
2020-04-12 00:26:44 +02:00
});
});
}
}