<?php

namespace Modules\Mall\Http\Resources\Api\Address;

use Illuminate\Http\Resources\Json\JsonResource;
use Modules\Mall\Http\Resources\Api\Region\RegionResource;

class AddressResource extends JsonResource
{

    public function toArray($request): array
    {
        return [
            'address_id'   => $this->id,
            'name'         => $this->name,
            'mobile'       => $this->mobile,
            'province'     => new RegionResource($this->province),
            'city'         => new RegionResource($this->city),
            'district'     => new RegionResource($this->district),
            'address'      => $this->address,
            'full_address' => $this->getFullAddress(),
            'default'      => $this->is_default,
            'created_at'   => (string) $this->created_at,
            'updated_at'   => (string) $this->updated_at,
        ];
    }

}
