Add: Get birthday from member

This commit is contained in:
philipp lang 2020-06-30 00:05:36 +02:00
parent 5a4fa4d5ec
commit 431dfb68fe
2 changed files with 8 additions and 9 deletions

View File

@ -2,18 +2,11 @@
namespace Zoomyboy\LaravelNami;
use \ArrayAccess;
use Illuminate\Support\Arr;
use Illuminate\Database\Eloquent\Concerns\HasAttributes;
use Illuminate\Database\Eloquent\Concerns\HidesAttributes;
use Illuminate\Contracts\Support\Arrayable;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
class Member extends Model {
use HasAttributes;
use HidesAttributes;
protected static $overviewAttributes = [
'vorname' => 'firstname',
'nachname' => 'lastname',
@ -32,7 +25,8 @@ class Member extends Model {
'geschlechtId' => 'gender_id',
'emailVertretungsberechtigter' => 'email_parents',
'staatsangehoerigkeitId' => 'nationality_id',
'konfessionId' => 'confession_id'
'konfessionId' => 'confession_id',
'geburtsDatum' => 'birthday'
];
protected $guarded = [];
@ -51,6 +45,10 @@ class Member extends Model {
parent::__construct($member);
}
public function getBirthdayAttribute() {
return Carbon::parse($this->attributes['birthday'])->format('Y-m-d');
}
public function getGenderIdAttribute() {
return $this->attributes['gender_id'] == Gender::getNullValue() ? null : $this->attributes['gender_id'];
}

View File

@ -33,6 +33,7 @@ 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']]
];
}