Update Doctors

This commit is contained in:
R
2022-09-20 10:57:10 +07:00
parent 07bfbaefe0
commit d187b9331d
7 changed files with 88 additions and 14 deletions

View File

@@ -14,6 +14,38 @@ class DoctorResource extends JsonResource
*/
public function toArray($request)
{
return parent::toArray($request);
$practices = $this->practitionerRoles->map(function($practitionerRole) {
return [
'id' => $practitionerRole->id,
'doctor_id' => $practitionerRole->practitioner_id,
'hospital_id' => $practitionerRole->organization_id,
'speciality_id' => $practitionerRole->speciality_id,
'hospital' => HospitalResource::make($practitionerRole->organization),
'speciality' => SpecialityResource::make($practitionerRole->speciality)
];
});
return [
'id' => $this->id,
'full_name' => $this->person->full_name ?? null,
'name_prefix' => $this->person->name_prefix ?? null,
'name' => $this->person->name ?? null,
'name_suffix' => $this->person->name_suffix ?? null,
'gender' => $this->person->gender ?? null,
// 'speciality_name' => !empty($this->speciality->name ?? null) ? 'Spesialis '. $this->speciality->name : 'Spesialis Empty',
'is_online' => false,
// 'is_insurance_covered' => rand(0,1) == 1,
// 'price_range' => 'Rp 100.000 - Rp 350.000',
// 'price_start' => '100000',
// 'price_end' => '350000',
'avatar_url' => asset('images/default-doctor-avatar.png'),
'education' => $this->meta->education ?? '',
'medical_treatment' => $this->meta->medical_treatment ?? '',
'award' => $this->meta->award ?? '',
'work_experience' => $this->meta->work_experience ?? '',
'keilmuan' => $this->meta->keilmuan ?? '',
'description' => $this->meta->description ?? '',
'practices' => $practices
];
}
}