Files
aso/Modules/Client/Transformers/EmployeeData/UserProfile/DataMemberResource.php
Linksehat Staging Server 70fc1579e7 update
2024-07-12 08:41:18 +07:00

47 lines
1.9 KiB
PHP
Executable File

<?php
namespace Modules\Client\Transformers\EmployeeData\UserProfile;
use Illuminate\Http\Resources\Json\JsonResource;
class DataMemberResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request
* @return array
*/
public function toArray($request)
{
return [
'person' => [
'name' => $this->full_name ?? null,
'weight' => $this->person->last_weight_kg ?? null,
'height' => $this->person->last_height_kg ?? null,
'placeOfBirth' => ucwords($this->person->birth_place) ?? null,
'dateOfBirth' => $this->birth_date ?? $this->person->birth_date,
'gender' => ucwords(strtolower($this->gender ?? $this->person->gender)),
'phoneNumber' => $this->person->phone ?? null,
'email' => $this->email ?? ($this->person->email ?? null),
'address' => $this->person->last_height_kg ?? null,
'idNumber' => $this->person->nik ?? null,
'religion' => ucwords(strtolower($this->person->religion)) ?? null,
'maritalStatus' => $this->marital_status,
'education' => ucwords(strtolower($this->person->last_education)) ?? null,
'occupation' => null,
],
'families' => collect($this->families)->map(function ($family) {
return [
'name' => $family->full_name ?? null,
'relationship' => $family->relationship ?? null,
'dateOfBirth' => $family->birth_date ?? $family->person->birth_date,
'email' => $this->email ?? ($this->person->email ?? null),
'phoneNumber' => $this->person->phone ?? null,
'status' => $this->status ?? null
];
})->all()
];
}
}