fix cleint portal employee-data, dashboard, hide notification

This commit is contained in:
Muhammad Fajar
2023-12-31 23:44:43 +07:00
parent ae884f8cd0
commit 96034d069a
26 changed files with 684 additions and 804 deletions

View File

@@ -63,7 +63,8 @@ class Member extends Model
"policy_in_force",
"start_no_claim",
"end_no_claim",
"suspended"
"suspended",
"active",
];
protected $appends = [
@@ -152,14 +153,14 @@ class Member extends Model
public function currentPlans()
{
return $this->hasManyThrough(Plan::class, MemberPlan::class, 'member_id', 'id', 'id', 'plan_id');
// ->latest(); // TODO Fix This
// ->latest(); // TODO Fix This
}
public function currentPlan()
{
return $this->hasOneThrough(Plan::class, MemberPlan::class, 'member_id', 'id', 'id', 'plan_id', )
->latest();
// ->where('plans.service_code', $this->claimRequest->service_code); // TODO Fix This
return $this->hasOneThrough(Plan::class, MemberPlan::class, 'member_id', 'id', 'id', 'plan_id',)
->latest();
// ->where('plans.service_code', $this->claimRequest->service_code); // TODO Fix This
}
// public function currentPlan()
@@ -230,7 +231,7 @@ class Member extends Model
$arr[] = $this->person->name_prefix;
}
$arr[] = $this->person->name;
$arr[] = $this->person->name ?? '-';
if (!empty($this->person->name_suffix)) {
$arr[] = $this->person->name_suffix;
@@ -258,19 +259,33 @@ class Member extends Model
// protected function birthDate(): Attribute
// {
// // $date = $this->person->birth_date ?? ($this->birth_date ?? null);
// $date = $this->birth_date ?? ($this->person->birth_date ?? null);
// return Attribute::make(
// get: fn () => !empty($date) ? Carbon::parse($date)->format('Y-m-d') : null
// );
// $date = $this->birth_date;
// if ($date){
// $date = ($this->birth_date ?? $this->person->birth_date);
// return Attribute::make(
// get: fn () => !empty($date) ? Carbon::parse($date)->format('d / M / Y') : '-'
// );
// } else {
// return Attribute::make(
// get: fn () => '-'
// );
// }
// }
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
);
$date = $this->birth_date;
if ($date) {
$date = ($this->birth_date ?? $this->person->birth_date);
return Attribute::make(
get: fn () => !empty($date) ? Carbon::parse($date)->format('d / M / Y') : '-'
);
} else {
return Attribute::make(
get: fn () => '-'
);
}
}
protected function startDate(): Attribute
@@ -291,18 +306,19 @@ class Member extends Model
);
}
protected function gender(): Attribute
{
return Attribute::make(
get: fn () => ucfirst($this->person->gender) ?? null
);
}
// protected function gender(): Attribute
// {
// return Attribute::make(
// get: fn () => $this->person->gender ? ucfirst($this->person->gender) : '-'
// // get: fn () => '-'
// );
// }
protected function corporateLogo(): Attribute
{
$avatar = File::where(['type' => 'avatar', 'fileable_id' => $this->currentPolicy->corporate->id])->orderBy('id', 'desc')->get()->first();
if ($avatar){
$path = $_ENV['LMS_APP_STORAGE'] . $avatar->path ? $avatar->path :'';
if ($avatar) {
$path = $_ENV['LMS_APP_STORAGE'] . $avatar->path ? $avatar->path : '';
return Attribute::make(
get: fn () => $avatar ? $path : null
);