<?php

namespace Modules\Client\Transformers\Dashboard;

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)
    {
        // dd($this->currentPlans);
        return [
            'id' => $this->id,
            'memberId' => $this->member_id,
            'fullName' => $this->full_name,
            'division' => $this->division_name ?? '',
            'limit' => [
                'current' => $this->claims_sum_total_claim ?? 0,
                'total' => $this->currentPlan->limit_rules ?? 0,
                'percentage' => (!empty($this->currentPlan->limit_rules ?? 0)) ? (($this->claims_sum_total_claim / $this->currentPlan->limit_rules) * 100) : 0
            ],
            'status' => $this->active,
            // 'service_type' => $this->currentPlans,
        ];
    }
}
