<?php

namespace App\Http\Resources\Pertanian;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Http\Resources\Wilayah\DesaKelurahanResource;

class TanamanResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'nama' => $this->nama,
            'komoditas' => $this->komoditas ? new KomoditasResource($this->komoditas) : null,
            'profile_id' => $this->profile_id,
            'lahan' => $this->lahan ? new LahanResource($this->lahan) : null,
            'latitude' => $this->latitude,
            'longitude' => $this->longitude,
            'kondisi_tanaman' => $this->kondisi_tanaman,
        ];
    }
}
