<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use App\Http\Resources\LoadingLinesResource;
use Illuminate\Http\Resources\Json\JsonResource;

class LoadingResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            "id" => $this->id,
            "farm_id" => $this->farm_id,
            "farm_name" => $this->farm_name,
            "building_id" => $this->building_id,
            "building_name" => $this->building_name,
            // "batch" => [
            //     "id" => $this->batch_id,
            //     "batch_no" => $this->batch_no,
            // ],
            "loading_date" => $this->loading_date,
            "total_initial" => $this->total_initial,
            "total_reject" => $this->total_reject,
            "total_doa" => $this->total_doa,
            "total_net" => $this->total_net,
            "sample_count" => $this->sample_count,
            "status" => $this->status,
            "synced_id" => $this->synced_id,
            "synced_status" => $this->synced_status,
            "synced_at" => $this->synced_at,
            "vet_acknowledged_by" => $this->vet_acknowledged_by,
            "vet_acknowledged_at" => $this->vet_acknowledged_at,
            "vet_notes" => $this->vet_notes,
            "hr_acknowledged_by" => $this->hr_acknowledged_by,
            "hr_acknowledged_at" => $this->hr_acknowledged_at,
            "hr_notes" => $this->hr_notes,
            "remarks" => $this->remarks,
            "created_at" => $this->created_at,
            "updated_at" => $this->updated_at,
            "deleted_at" => $this->deleted_at,
            "lead_man" => new UserSummaryResource($this->leadman),
            "caretaker" => new UserSummaryResource($this->caretaker),
            "loading_lines" => LoadingLinesResource::collection(
                $this->loadingLines
            ),
            "batch" => new BatchResource($this->batch),
        ];
    }
}
