<?php

namespace Modules\Linksehat\Transformers;

use Illuminate\Http\Resources\Json\JsonResource;

class PractitionerRoleToDoctorDetailResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'full_name' => $this->practitioner->person->full_name ?? null,
            'name_prefix' => $this->practitioner->person->name_prefix ?? null,
            'name' => $this->practitioner->person->name ?? null,
            'name_suffix' => $this->practitioner->person->name_suffix ?? null,
            'gender' => $this->practitioner->person->gender ?? null,
            'speciality_name' => !empty($this->speciality->name ?? null) ? 'Spesialis '. $this->speciality->name : 'Spesialis Empty',
            'is_online' => false,
            'is_insurance_covered' => rand(0,1) == 1,
            'price_range' => 'Rp 100.000 - Rp 350.000',
            'price_start' => '100000',
            'price_end' => '350000',
            'currency' => 'IDR',
            'avatar_url' => asset('images/default-doctor-avatar.png'),
            'education' => $this->meta->education ?? '',
            'medical_treatment' => $this->meta->medical_treatment ?? '',
            'award' => $this->meta->award ?? '',
            'work_experience' => $this->meta->work_experience ?? '',
            'keilmuan' => $this->meta->keilmuan ?? '',
            'length_of_work_year' => rand(1, 10),
            'description' => $this->meta->description ?? '',
            'rating' => rand(88, 100),
            
            'is_chat_available' => $this->is_chat_available,
            'is_video_available' => $this->is_video_available,
            'is_walkin_available' => $this->is_walkin_available,
            'is_instant_chat_available' => $this->is_instant_chat_available,
        ];

        return parent::toArray($request);
    }
}
