Client Portal - Employee Data
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?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()
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user