<?php

namespace Modules\User\Models\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use Modules\City\Models\Resources\CityResource;
use Modules\Country\Models\Resources\CountryResource;
use Modules\Region\Models\Resources\RegionResource;

class AddressResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'user_name'=>$this->user_name,
            'phone'=>$this->phone,
            'address'=>$this->address,
            'latitude'=>$this->latitude,
            'longitude'=>$this->longitude,
            'delivery_status'=>$this->delivery_status,
            'country'=>new CountryResource($this->whenLoaded('country')),
            'region'=>new RegionResource($this->whenLoaded('region')),
            'city'=>new CityResource($this->whenLoaded('city')),

        ];
    }
}
