<?php

namespace Modules\User\Models\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use Modules\Type\Models\Resources\TypeResource;

class VisitorResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'role'=>'visitor',
            'language'=>$this->language,
            'type'=>new TypeResource($this->whenLoaded('type')),
            'address'=>new AddressResource($this->whenLoaded('address'))
        ];
    }
}
