Add gender id to member

This commit is contained in:
philipp lang 2020-06-29 23:29:54 +02:00
parent 8c70ed7c16
commit c0fe5623a8
6 changed files with 14 additions and 2 deletions

View File

@ -9,6 +9,10 @@ class Gender extends Model implements Nullable {
protected $guarded = [];
public static function getNullValue() {
return 23;
}
public static function fromNami($item) {
$item = collect($item)
->only(['descriptor', 'id'])
@ -25,7 +29,7 @@ class Gender extends Model implements Nullable {
}
public function getIsNullAttribute() {
return $this->attributes['name'] == 'keine Angabe';
return $this->attributes['id'] == self::getNullValue();
}
}

View File

@ -29,6 +29,7 @@ class Member extends Model {
'telefon3' => 'work_phone',
'telefax' => 'fax',
'email' => 'email',
'geschlechtId' => 'gender_id',
'emailVertretungsberechtigter' => 'email_parents'
];
@ -49,4 +50,8 @@ class Member extends Model {
parent::__construct($member);
}
public function getGenderIdAttribute() {
return $this->attributes['gender_id'] == Gender::getNullValue() ? null : $this->attributes['gender_id'];
}
}

View File

@ -6,4 +6,6 @@ interface Nullable {
public function getIsNullAttribute();
public static function getNullValue();
}

View File

@ -30,6 +30,7 @@ class PullMemberTest extends TestCase
'fax' => ['fax', ['+55111', '+55222']],
'email' => ['email', ['test@example.com', 'test2@example.com']],
'email_parents' => ['email_parents', ['testp@example.com', 'test2p@example.com']],
'gender_id' => ['gender_id', [19, null]],
];
}

View File

@ -47,7 +47,7 @@
"zahlungsKonditionId": null,
"zahlungsKondition": null
},
"geschlechtId": 19,
"geschlechtId": 23,
"land": "Deutschland",
"email": "test2@example.com",
"telefon1": "+49668",