2022-02-12 16:16:56 +01:00
|
|
|
<?php
|
2020-04-12 00:26:44 +02:00
|
|
|
|
|
|
|
namespace App\Initialize;
|
|
|
|
|
2022-02-19 18:06:07 +01:00
|
|
|
use App\Nationality;
|
2022-02-12 16:16:56 +01:00
|
|
|
use Zoomyboy\LaravelNami\Api;
|
|
|
|
|
2022-03-11 20:19:17 +01:00
|
|
|
class InitializeNationalities
|
|
|
|
{
|
2022-02-12 16:16:56 +01:00
|
|
|
private Api $api;
|
2020-04-12 00:26:44 +02:00
|
|
|
|
2022-03-11 20:19:17 +01:00
|
|
|
public function __construct(Api $api)
|
|
|
|
{
|
2020-04-12 00:26:44 +02:00
|
|
|
$this->api = $api;
|
|
|
|
}
|
|
|
|
|
2022-02-19 18:06:07 +01:00
|
|
|
public function handle(Api $api): void
|
2022-02-12 16:16:56 +01:00
|
|
|
{
|
2022-03-11 20:19:17 +01:00
|
|
|
$this->api->nationalities()->each(function ($nationality) {
|
2022-02-19 18:06:07 +01:00
|
|
|
Nationality::create(['nami_id' => $nationality->id, 'name' => $nationality->name]);
|
2020-04-12 00:26:44 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|