<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class HeadingItemResource 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 [
            'sample_id' => $this->id,
            'sample_type_id' => $this->sample_type_id,
            'group_result' => $this->group_result,
            'id' => $this->test_id,
            'name_en' => $this->whenLoaded('test', function (){
                return $this->test->name_en;
            })
        ];
    }
}
