<?php

namespace App\Http\Resources\OLDLMS;

use App\Services\ClaimService;
use App\Models\Corporate;
use Illuminate\Http\Resources\Json\JsonResource;


class MemberResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        // $data = parent::toArray($request);
        $currentMemberPlan = $this->memberPlans?->first();
        $limitTelecon = $currentMemberPlan->plan->limit_telecon ?? null;
        $limitTelecon = $this->totalUsage >= 6 ? null : $limitTelecon;

        $data = [
            'id' => $this->id,
            'member_name' => $this->full_name,
            'member_id' => $this->member_id,
            'policy_holder' => $this->currentPolicy->corporate->name,
            'policy_number' => $this->currentPolicy->code ?? null,
            'date_of_birth' => $this->birth_date,
            'gender' => $this->gender,
            'start_date' => $this->members_effective_date,
            'corporate_logo' => $_ENV['LMS_APP_STORAGE'] . $this->corporateLogo,
            'valid_until' => $this->members_expire_date,
           
        ];
        return $data;
    }
}
