From 7db0af3bef21041f2c4301e016b260d7b7310941 Mon Sep 17 00:00:00 2001 From: Tb Fajri Date: Sat, 6 Jan 2024 14:13:13 +0700 Subject: [PATCH] update fix member detail --- app/Models/Member.php | 69 +++++++++++++++++-- .../src/pages/Corporates/Member/List.tsx | 4 +- 2 files changed, 64 insertions(+), 9 deletions(-) diff --git a/app/Models/Member.php b/app/Models/Member.php index 6724d2bb..9f0f6e25 100644 --- a/app/Models/Member.php +++ b/app/Models/Member.php @@ -71,6 +71,9 @@ class Member extends Model 'full_name', 'age', 'gender_code', + 'relations', + 'status_marital' + // 'relation_with_principal' ]; protected $hidden = [ @@ -245,7 +248,7 @@ class Member extends Model protected function genderCode(): Attribute { return Attribute::make( - get: fn () => $this->gender ? ($this->gender == 'female' ? 'F' : 'M') : $this->gender + get: fn () => $this->gender ? ($this->gender == 'Female' ? 'F' : 'M') : $this->gender ); } @@ -256,6 +259,39 @@ class Member extends Model ); } + + protected function relations(): Attribute + { + $relation = '-'; + if ($this->relation_with_principal == 'H'){ + $relation = 'Husbund'; + } else if ($this->relation_with_principal == 'W'){ + $relation = 'Wife'; + } else if ($this->relation_with_principal == 'S'){ + $relation = 'Son'; + } else if ($this->relation_with_principal == 'D'){ + $relation = 'Daughter'; + } + return Attribute::make( + get: fn () => $relation + ); + } + + protected function statusMarital(): Attribute + { + $maritalStatus = '-'; + if ($this->marital_status == 'M'){ + $maritalStatus = 'Married'; + } else if ($this->relation_with_principal == 'D'){ + $maritalStatus = 'Divorced'; + } else if ($this->relation_with_principal == 'S'){ + $maritalStatus = 'Sungle'; + } + return Attribute::make( + get: fn () => $maritalStatus + ); + } + // protected function birthDate(): Attribute // { // // $date = $this->person->birth_date ?? ($this->birth_date ?? null); @@ -302,12 +338,31 @@ class Member extends Model ); } - protected function gender(): Attribute - { - return Attribute::make( - get: fn () => ucfirst($this->person->gender) ?? null - ); - } + // protected function relationWithPrincipal(): Attribute + // { + // $relation = null; + + // if ($this->relation_with_principal === 'S') { + // $relation = 'Son'; + // } elseif ($this->relation_with_principal === 'H') { + // $relation = 'Husband'; + // } elseif ($this->relation_with_principal === 'D') { + // $relation = 'Daughter'; + // } elseif ($this->relation_with_principal === 'Wife') { + // $relation = 'Wife'; + // } + + // return Attribute::make( + // get: fn () => $relation + // ); + // } + + // protected function gender(): Attribute + // { + // return Attribute::make( + // get: fn () => ucfirst($this->person->gender) ?? null + // ); + // } protected function corporateLogo(): Attribute { diff --git a/frontend/dashboard/src/pages/Corporates/Member/List.tsx b/frontend/dashboard/src/pages/Corporates/Member/List.tsx index 5c30fb60..86c13dbe 100644 --- a/frontend/dashboard/src/pages/Corporates/Member/List.tsx +++ b/frontend/dashboard/src/pages/Corporates/Member/List.tsx @@ -603,7 +603,7 @@ export default function CorporatePlanList({handleSubmitSuccess}) { NRIC: {row.nric ? row.nric : '-'} Marital Status: - {row.marital_status ? row.marital_status : '-'} + {row.status_marital ? row.status_marital : '-'} NIK: @@ -622,7 +622,7 @@ export default function CorporatePlanList({handleSubmitSuccess}) { Email: {row.email ? row.email : '-'} Relationship: - {row.relation_with_principal ? row.relation_with_principal : '-'} + {row.relations ? row.relations : '-'} Phone Number: