Files
hpt_inventory/app/Http/Resources/TestResource.php
2026-06-10 16:42:20 +07:00

32 lines
908 B
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class TestResource 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 [
'id' => (string) $this->id,
'group_result' => $this->group_result,
'closed_parent_id' => (string) ($this->heading_id > 0 ? $this->heading_id : 0),
'code' => $this->code,
'test_name' => $this->whenLoaded('test', function (){
return $this->test->name_en;
}),
'children' => null,
'price' => (string)$this->usd_price,
'test_heading' => $this->field_type== 0 ? 'test-heading' : ''
];
}
}