Remove genders that are null
This commit is contained in:
parent
cd3a165504
commit
0a34e92a5b
|
@ -156,7 +156,7 @@ class Api {
|
|||
public function genders(): Collection {
|
||||
return collect($this->http()->get(self::$url."/ica/rest/baseadmin/geschlecht")['data'])->map(function($gender) {
|
||||
return Gender::fromNami($gender);
|
||||
});
|
||||
})->filter(fn($gender) => !$gender->isNull);
|
||||
}
|
||||
|
||||
public function nationalities(): Collection {
|
||||
|
|
|
@ -14,22 +14,14 @@ class Gender extends Model implements Nullable {
|
|||
}
|
||||
|
||||
public static function fromNami($item) {
|
||||
$item = collect($item)
|
||||
->only(['descriptor', 'id'])
|
||||
->mapWithKeys(function($item,$key) {
|
||||
if ($key == 'id') { return ['id' => $item]; }
|
||||
return ['name' => $item];
|
||||
})->toArray();
|
||||
|
||||
return (new self($item));
|
||||
}
|
||||
|
||||
public function getNameAttribute() {
|
||||
return ucfirst($this->attributes['name']);
|
||||
return new self([
|
||||
'id' => $item['id'],
|
||||
'name' => ucfirst($item['descriptor'])
|
||||
]);
|
||||
}
|
||||
|
||||
public function getIsNullAttribute() {
|
||||
return $this->attributes['id'] == self::getNullValue();
|
||||
return $this->id == self::getNullValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ class PullGenderTest extends TestCase
|
|||
Nami::login();
|
||||
|
||||
$this->assertEquals([
|
||||
23 => 'Keine Angabe',
|
||||
19 => 'Männlich',
|
||||
20 => 'Weiblich'
|
||||
], Nami::genders()->pluck('name', 'id')->toArray());
|
||||
|
@ -29,16 +28,4 @@ class PullGenderTest extends TestCase
|
|||
Http::assertSentCount(3);
|
||||
}
|
||||
|
||||
public function test_a_gender_can_be_null() {
|
||||
Http::fake(array_merge($this->login(), $this->fakeGenders()));
|
||||
|
||||
$this->setCredentials();
|
||||
|
||||
Nami::login();
|
||||
|
||||
$this->assertEquals([true, false, false], Nami::genders()->pluck('isNull')->toArray());
|
||||
|
||||
Http::assertSentCount(3);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue