<?php

namespace Modules\Linksehat\Transformers;

use Illuminate\Http\Resources\Json\JsonResource;

class UserProfileResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'email' => $this->email,
            'phone' => $this->phone,
            'email_verified_at' => $this->email_verified_at,
            'nik' => $this->person->nik ?? null, 
            'name_prefix' => $this->person->name_prefix ?? null,
            'name' => $this->person->name ?? null,
            'name_suffix' => $this->person->name_suffix ?? null,
            'full_name' => $this->person->full_name ?? null,
            'gender' => $this->person->gender ?? null,
            'birth_date' => $this->person->birth_date ?? null,
            'age' => $this->person->age ?? null,
            'is_deceased' => $this->person->is_deceased ?? null,
            'deceased_at' => $this->person->deceased_at ?? null,
            'marital_status' => $this->person->marital_status ?? null,
            'preferred_lang' => $this->meta->preferred_lang ?? 'id',
        ];
    }
}
