<?php

namespace Modules\Internal\Transformers;

use App\Models\Benefit;
use Illuminate\Http\Resources\Json\JsonResource;

class ClaimEditResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request
     * @return array
     */
    public function toArray($request)
    {
        $value = parent::toArray($request);
        $data['id'] = $value['id'];
        $data['plan_id'] = $value['plan'] ? $value['plan']['code'] : '-';
        $data['payor_id'] = $value['member'] ? $value['member']['current_corporate']['payor_id'] : '-';
        $data['corporate_id'] = $value['member'] ? $value['member']['current_corporate']['code'] : '-';
        $data['policy_number'] = $value['member'] ? $value['member']['current_policy']['code'] : '-';
        $data['member_id'] = $value['member'] ? $value['member']['member_id'] : '-';
        // $data['benefit_code'] = $value['benefit'] ? $value['benefit']['code'] : '-';
        // $data['benefit_desc'] = $value['benefit'] ? $value['benefit']['description'] : '-';
        $data['benefit_code'] = $value['benefit_code'];
        $data['benefit_desc'] = $value['benefit_desc'];
        $data['amount_incurred'] = $value['amount_incurred'];
        $data['amount_approved'] = $value['amount_approved'];
        $data['amount_not_approved'] = $value['amount_not_approved'];
        $data['excess_paid'] = $value['excess_paid'];

        return $data;
    }
}
