<?php

namespace App\Http\Resources\V1;

use Illuminate\Http\Resources\Json\JsonResource;

class LocationResource extends JsonResource
{


    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {


        return [
            'id'              => $this->id,
            'name'            => $this->title,
            'tags'            => TagResource::collection($this->whenLoaded('tags')),
            'mapPositionLat'  => $this->map_position->latitude,
            'mapPositionLng'  => $this->map_position->longitude,
            'mapPositionZoom' => $this->map_position_zoom,
            'description'     => $this->description,
            'openingHours'    => $this->opening_hours,
            'address'         => $this->address,
            'website'         => $this->website,
            'city'            => new CityResource($this->whenLoaded('city')),
            'cityZone'        => new CityZoneResource($this->whenLoaded('cityZone')),
            'image'           => new ImageResource($this->whenLoaded('image')),
            'exhibitions'     => ExhibitionResource::collection($this->whenLoaded('exhibitions')),
        ];
    }
}
