<?php

namespace Modules\Internal\Transformers;

use Illuminate\Http\Resources\Json\JsonResource;

class OrganizationResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request
     * @return array
     */
    public function toArray($request)
    {
        $organization = [
            'id' => $this->id,
            'name' => $this->name,
            'type' => $this->type,
            'code' => $this->code,
            'description' => $this->description,
            'kodeRs' => $this->meta->kodeRs ?? null,
            'phone' => $this->meta->phone ?? null,
            'lat' => $this->currentAddress->lat ?? null,
            'lng' => $this->currentAddress->lng ?? null,
            'address' => $this->currentAddress ?? null,
        ];

        return $organization;
    }
}
