33 lines
1.0 KiB
PHP
33 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Modules\Client\Transformers;
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class MemberResources extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'memberId' => $this->member_id,
|
|
'fullName' => $this->full_name,
|
|
$this->mergeWhen($request->input('claimMember') === 'false', [
|
|
'division' => $this->division->name ?? '',
|
|
'status' => $this->active
|
|
]),
|
|
'limit' => [
|
|
'current' => $this->claims_sum_total_claim,
|
|
'total' => $this->currentPlan->limit_rules ?? 0,
|
|
'percentage' => (!empty($this->currentPlan->limit_rules ?? 0)) ? (($this->claims_sum_total_claim / $this->currentPlan->limit_rules) * 100) : 0
|
|
],
|
|
];
|
|
}
|
|
}
|