<?php

namespace Modules\Client\Transformers\ClaimReport;

use Illuminate\Http\Resources\Json\JsonResource;

class ShowResources extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'claimRequestId' => $this->id,
            'claimId' => $this->claim_id,
            'submissionDate' => $this->submission_date,
            'histories' => $this->whenLoaded('histories'),
            'fullName' => $this->whenLoaded('member', $this->member->full_name),
            'status' => $this->status,
            'files' => [
                'claimResults' => ClaimReportFileShowResources::collection($this->whenLoaded('claimResults')),
                'claimConditions' => ClaimReportFileShowResources::collection($this->whenLoaded('claimConditions')),
                'claimDiagnosis' => ClaimReportFileShowResources::collection($this->whenLoaded('claimDiagnosis'))
            ]
        ];
    }
}
