From 6997ff07f1f041c5961ce2e5a7601d68a4d57b34 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Tue, 30 Jun 2020 00:07:53 +0200 Subject: [PATCH] Add joined at attribute --- src/Member.php | 7 ++++++- tests/Unit/PullMemberTest.php | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Member.php b/src/Member.php index 3c47658..435920e 100644 --- a/src/Member.php +++ b/src/Member.php @@ -26,7 +26,8 @@ class Member extends Model { 'emailVertretungsberechtigter' => 'email_parents', 'staatsangehoerigkeitId' => 'nationality_id', 'konfessionId' => 'confession_id', - 'geburtsDatum' => 'birthday' + 'geburtsDatum' => 'birthday', + 'eintrittsdatum' => 'joined_at', ]; protected $guarded = []; @@ -49,6 +50,10 @@ class Member extends Model { return Carbon::parse($this->attributes['birthday'])->format('Y-m-d'); } + public function getJoinedAtAttribute() { + return Carbon::parse($this->attributes['joined_at'])->format('Y-m-d'); + } + public function getGenderIdAttribute() { return $this->attributes['gender_id'] == Gender::getNullValue() ? null : $this->attributes['gender_id']; } diff --git a/tests/Unit/PullMemberTest.php b/tests/Unit/PullMemberTest.php index 64fc708..19cee1b 100644 --- a/tests/Unit/PullMemberTest.php +++ b/tests/Unit/PullMemberTest.php @@ -33,7 +33,8 @@ class PullMemberTest extends TestCase 'gender_id' => ['gender_id', [19, null]], 'nationality_id' => ['nationality_id', [1054, null]], 'confession_id' => ['confession_id', [1, null]], - 'birthday' => ['birthday', ['1991-06-20', '1984-01-17']] + 'birthday' => ['birthday', ['1991-06-20', '1984-01-17']], + 'joined_at' => ['joined_at', ['2005-05-01', '2003-11-17']], ]; }