update ecard dan enrolment 2

This commit is contained in:
2024-01-06 12:35:58 +07:00
parent a9c48f63a4
commit 5c5ad8bae7
3 changed files with 23 additions and 11 deletions

View File

@@ -340,8 +340,10 @@ class MemberEnrollmentService
if ($date_from_row instanceof DateTime) {
return $date_from_row->format('Y-m-d');
} else {
} else if ($date_from_row != null) {
return date('Y-m-d', strtotime($date_from_row));
} else {
return null;
}
}
@@ -728,7 +730,7 @@ class MemberEnrollmentService
],
[
'name' => $row['name'] ?? null,
'birth_date' => $this->dateParser($row['date_of_birth']),
'birth_date' => $this->dateParser($row['date_of_birth']) ?? null,
'gender' => Helper::genderNormalization($row['sex']),
'language' => $row['language'] ?? null,
'race' => $row['race'] ?? null,
@@ -785,7 +787,7 @@ class MemberEnrollmentService
if ($member->save()) {
$person = Person::create([
'name' => $row['name'],
'birth_date' => $this->dateParser($row['date_of_birth']),
'birth_date' => $this->dateParser($row['date_of_birth']) ?? null,
'gender' => Helper::genderNormalization($row['sex']) ?? '-',
'language' => $row['language'] ?? null,
'race' => $row['race'] ?? null,
@@ -906,6 +908,7 @@ class MemberEnrollmentService
$member->gender = Helper::genderPerson($row['sex']);
$member->relation_with_principal = $row['relationship_with_principal'];
$member->marital_status = $row['marital_status'];
$member->birth_date = $this->dateParser($row['date_of_birth']);
$member->save();
try {
@@ -937,7 +940,7 @@ class MemberEnrollmentService
// $memberPlan->plan_id = $plan->id;
// $memberPlan->save();
// }
// Hapus Member plan terkait
$member->memberPlans()->delete();
//Update plan
@@ -999,7 +1002,7 @@ class MemberEnrollmentService
'sNamaPeserta' => $row['name'],
'dStartDate' => $row['member_effective_date'],
'dExpireDate' => $row['member_expiry_date'],
'dTanggalLahir' => $row['date_of_birth'],
'dTanggalLahir' => $row['date_of_birth'] ? $this->dateParser($row['date_of_birth']) : null,
// 'nNoKTP' => $row['nric'] ?? ,
]
);

View File

@@ -268,10 +268,20 @@ class Member extends Model
protected function birthDateeCard(): Attribute
{
// $date = $this->person->birth_date ?? ($this->birth_date ?? null);
$date = $this->birth_date ?? ($this->birth_date ?? this->person->birth_date);
return Attribute::make(
get: fn () => !empty($date) ? Carbon::parse($date)->format('d / M / Y') : null
);
if ($this->birth_date){
$date = $this->birth_date;
return Attribute::make(
get: fn () => !empty($date) ? Carbon::parse($date)->format('d / M / Y') : null
);
} else if ($this->person->birth_date){
return Attribute::make(
get: fn () => !empty($date) ? Carbon::parse($date)->format('d / M / Y') : null
);
} else {
return Attribute::make(
get: fn () => '-'
);
}
}
protected function startDate(): Attribute

View File

@@ -77,10 +77,9 @@
</style>
</head>
<body>
<br><br><br><br>
<br><br>
@if($member->currentCorporate->files && count($member->currentCorporate->files) > 0)
<div>
{{ asset($member->currentCorporate->files[0]->path)}}
<img src="{{ public_path('images/logo-default.png') }}" height="30px">
</div>
@endif