HEX
Server: nginx/1.24.0
System: Linux DGT-WORDPRESS-VM-SERVER 6.14.0-1017-azure #17~24.04.1-Ubuntu SMP Mon Dec 1 20:10:50 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 8.4.12
Disabled: NONE
Upload Files
File: /mnt/data/ghayatcom/ghayatcom-api/app/Http/Resources/AppointmentResource.php
<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;
use App\Enums\AppoitmentStatusEnum;

/**
 * App\Http\Resources
 *
 * @property integer $id
 * @property integer $consultation_type
 * @property mixed $consultation_type_str
 * @property mixed $consultation_id
 * @property mixed $sick_leave_verification
 * @property integer $patient_id
 * @property integer $doctor_id
 * @property mixed $tokbox_session_id
 * @property mixed $tokbox_token
 * @property mixed $appointment_start_dt
 * @property mixed $appointment_end_dt
 * @property mixed $home_visit_dt
 * @property mixed $home_visit_range
 * @property mixed $departure_time
 * @property mixed $on_my_way_time
 * @property object $appointment_status
 * @property mixed $consultation_end_time
 * @property mixed $lat_long_address
 * @property mixed $price_detail
 * @property mixed $consultation_cost
 * @property mixed $referal_pdf
 * @property mixed $is_avail_insurance_claim_details
 * @property mixed $insurance_claim_status
 * @property mixed $is_avail_insurance_claim_details
 * @property object $doctorDetails
 * @property object $appointmentReason
 * @property object $appointmentSymptoms
 * @property object $appointment_request_detail
 * @property object $patientDetails
 * @property object $insuranceDetails
 * @property object $diagnosisDetails
 */

class AppointmentResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    private $insuranceDetail;
    public function __construct($resource, $insuranceDetail = '') {
        parent::__construct($resource);
        $this->insuranceDetail = $insuranceDetail;
    }

    public function toArray($request)
    {
        $insuranceDetail = ($this->insuranceDetail !='') ? [
            'id' =>$this->insuranceDetail->id,
            'insurance_company' =>$this->insuranceDetail->insurance_company,
            'policy_number' =>$this->insuranceDetail->policy_number,
            'company_name' =>$this->insuranceDetail->company_name,
            'cover_from' =>$this->insuranceDetail->cover_from,
            'cover_to' =>$this->insuranceDetail->cover_to,
            'insurance_type' =>$this->insuranceDetail->insurance_type,
            'first_name' =>$this->insuranceDetail->first_name,
            'last_name' =>$this->insuranceDetail->last_name,
            'passport_number' =>$this->insuranceDetail->passport_number,
            'dob' =>$this->insuranceDetail->dob,
            'country_id ' =>$this->insuranceDetail->country_id,
            'post_code ' =>$this->insuranceDetail->post_code,
            'address' =>$this->insuranceDetail->address,
            'country_code' =>$this->insuranceDetail->country_code,
            'mobile_number' =>$this->insuranceDetail->mobile_number,
            'email' =>$this->insuranceDetail->email,
        ] : [];

        return [
            'id' => $this->id,
            'consultation_type' => $this->consultation_type,
            'consultation_type_str' =>$this->consultation_type_str,
            'consultation_id' => $this->consultation_id,
            'sick_leave_verification' => ($this->sick_leave_verification == 1) ? 'Yes' : 'No',
            'patient_id' => $this->patient_id,
            'doctor_id' => $this->doctor_id,
            'tokbox_session_id' => $this->tokbox_session_id,
            'tokbox_token' => $this->tokbox_token,
            'appointment_start_dt' => $this->appointment_start_dt,
            'appointment_end_dt' => $this->appointment_end_dt,
            'consultation_end_time' => $this->consultation_end_time,
            'home_visit_dt' => $this->home_visit_dt,
            'home_visit_range' => $this->home_visit_range,
            'departure_time' => $this->departure_time,
            'on_my_way_time' => $this->on_my_way_time,
            'appointment_status' => $this->appointment_status,
            'lat_long_address' => $this->lat_long_address,
            'price_detail' => $this->price_detail,
            'consultation_cost' => $this->consultation_cost,
            'referal_pdf' => $this->referal_pdf,
            'is_avail_insurance_claim_details' => $this->is_avail_insurance_claim_details,
            'insurance_claim_status' => ($this->insurance_claim_status == 1 ? "AWAITING REPORT FROM DOCTOR":($this->insurance_claim_status == 2 ? "ACCEPTED":($this->insurance_claim_status == 3 ? "COMPLETED":($this->insurance_claim_status == 4 ? "REJECTED":"")))),
            'appointment_request_detail' =>$this->appointment_request_detail,
            'patient_detail' =>[
                'id' =>$this->patientDetails->id,
                'unique_id' =>$this->patientDetails->unique_id,
                'first_name' =>$this->patientDetails->first_name,
                'last_name' =>$this->patientDetails->last_name,
                'country_code' =>$this->patientDetails->country_code,
                'mobile_number' =>$this->patientDetails->mobile_number,
                'passport_number' => $this->patientDetails->passport_number,
                'email' =>$this->patientDetails->email,
                'dob' =>$this->patientDetails->dob,
                'age' => $this->patientDetails->dob != "" ? (date('Y') - date('Y',strtotime($this->patientDetails->dob))):"",
                'gender' =>$this->patientDetails->gender,
                'profile_image' =>$this->patientDetails->profile_image,
                'status' =>$this->patientDetails->status,
                'insurance_detail' => $insuranceDetail
            ],
            'doctor_detail' =>[
                'id' =>$this->doctorDetails->id,
                'first_name' =>$this->doctorDetails->first_name,
                'last_name' =>$this->doctorDetails->last_name,
                'country_code' =>$this->doctorDetails->country_code,
                'mobile_number' =>$this->doctorDetails->mobile_number,
                'email' =>$this->doctorDetails->email,
                'profile_image' =>$this->doctorDetails->profile_image,
                'dob' =>$this->doctorDetails->dob,
                'age' => $this->patientDetails->dob != "" ? (date('Y') - date('Y',strtotime($this->patientDetails->dob))):"",
                'gender' =>$this->doctorDetails->gender,
                'status' =>$this->doctorDetails->status,
                'passport_number' =>$this->doctorDetails->passport_number,
                'avgratingdoctor' =>$this->doctorDetails->avgratingdoctor,
                'isfavourite' =>$this->doctorDetails->isfavourite,
                'medical_council_no' => $this->doctorDetails->userDetail->medical_council_regno,
                'doctor_consultation' => [
                    'home_visit' => $this->doctorDetails->userDetail->home_visit,
                    'on_demand' => $this->doctorDetails->userDetail->on_demand,
                    'schedule_appointment' => $this->doctorDetails->userDetail->schedule_appointment,
                    'audio_call' => $this->doctorDetails->userDetail->audio_call,
                    'chat' => $this->doctorDetails->userDetail->chat,
                    'video_call' => $this->doctorDetails->userDetail->video_call,
                    'hospital_visit' => $this->doctorDetails->userDetail->hospital_visit,
                    'scheduled_cost' => [
                        'schedule_appointment_currency_code' => $this->doctorDetails->userDetail->schedule_appointment_currency_code,
                        'schedule_appointment_price' => $this->doctorDetails->userDetail->schedule_appointment_price
                    ],
                    'home_visit_cost' => [
                        'home_visit_currency_code' => $this->doctorDetails->userDetail->home_visit_currency_code,
                        'home_visit_price' => $this->doctorDetails->userDetail->home_visit_price
                    ],
                    'ondemand_cost' => [
                        'on_demand_currency_code' => $this->doctorDetails->userDetail->on_demand_currency_code,
                        'on_demand_price' => $this->doctorDetails->userDetail->on_demand_price
                    ]
                ],
                'ondemand_online_status' => $this->doctorDetails->userDetail->ondemand_status
            ],
            'reasons' =>[
                'id'=> $this->appointmentReason->id,
                'reason'=> $this->appointmentReason->reasons_text,
                'reasons_document'=> json_decode($this->appointmentReason->reasons_document),
                'reasons_document_str' =>$this->appointmentReason->reason_documents_str,
                'reasons_document_url' =>$this->appointmentReason->reason_documents
            ],
            'appointmentSymptom'=> $this->appointmentSymptoms,
            'insuranceClaimDetails'=> isset($this->insuranceClaimDetails)?$this->insuranceClaimDetails:[],
            'appointmentHealthRecords'=> isset($this->appointmentHealthRecord)?$this->appointmentHealthRecord:[],
            'appointmentHealthRecordSymptoms'=> isset($this->appointmentHealthRecordSymptoms)?$this->appointmentHealthRecordSymptoms:[],
            'diagnosisDetails'=> isset($this->diagnosisDetails)?$this->diagnosisDetails:NULL,
            'payment_detail'=> isset($this->paymentDetails)?$this->paymentDetails:NULL,
        ];

    }
}