<?php

namespace Modules\Address\Resources\Api;

use Illuminate\Http\Resources\Json\JsonResource;
use Modules\City\Resources\Api\CityResource;

class AddressResource extends JsonResource
{

    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        $return = [
            'id' => (int) $this->id,
            'latitude' => (double) $this->latitude,
            'longitude' => (double) $this->longitude,
            'description' => $this->description,
            'city' => new CityResource($this->city),
        ];

        return $return;
    }

}
