Files
aso/Modules/Client/Transformers/DataMemberResource.php

82 lines
3.2 KiB
PHP

<?php
namespace Modules\Client\Transformers;
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 parent::toArray($request);
$data = [
'id' => $this->id,
'person_id' => $this->person_id,
'user_id' => $this->user_id,
'member_id' => $this->member_id,
'payor_id' => $this->payor_id,
'name_prefix' => $this->name_prefix,
'name' => $this->name,
'name_suffix' => $this->name_suffix,
'birth_date' => $this->birth_date,
'gender' => $this->gender,
'language' => $this->language,
'race' => $this->race,
'marital_status' => $this->marital_status,
'record_type' => $this->record_type,
'principal_id' => $this->principal_id,
'relation_with_principal' => $this->relation_with_principal,
'bpjs_class' => $this->bpjs_class,
'nric' => $this->nric,
'email' => $this->email,
'bank_info' => $this->bank_info,
'agent_code' => $this->agent_code,
'address1' => $this->address1,
'address2' => $this->address2,
'address3' => $this->address3,
'address4' => $this->address4,
'city' => $this->city,
'state' => $this->state,
'postal_code' => $this->postal_code,
'record_mode' => $this->record_mode,
'telephone_mobile' => $this->telephone_mobile,
'telephone_res' => $this->telephone_res,
'telephone_office' => $this->telephone_office,
'passport_no' => $this->passport_no,
'passport_country' => $this->passport_country,
'identification_code' => $this->identification_code,
'pre_existing' => $this->pre_existing,
'bpjs_id' => $this->bpjs_id,
'endorsement_date' => $this->endorsement_date,
'members_effective_date' => $this->members_effective_date,
'members_expire_date' => $this->members_expire_date,
'activation_date' => $this->activation_date,
'terminated_date' => $this->terminated_date,
'remarks' => $this->remarks,
'policy_in_force' => $this->policy_in_force,
'start_no_claim' => $this->start_no_claim,
'end_no_claim' => $this->end_no_claim,
'active' => $this->active,
'reason' => $this->reason,
'total_claims' => $this->total_claims,
'full_name' => $this->full_name,
'age' => $this->age,
'gender_code' => $this->gender_code,
'limit' => [
'current' => $this->total_claims ?? 0,
'total' => (int)$this->currentPlan->limit_rules ?? 0,
'percentage' => (!empty($this->currentPlan->limit_rules ?? 0)) ? (($this->total_claims / $this->currentPlan->limit_rules) * 100) : 0
],
'benefits' => $this->currentPlan->benefits,
];
return $data;
}
}