File: /mnt/data/ghayatcom/ghayatcom-api/app/Http/Resources/PrescriptionResource.php
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* App\Http\Resources
*
* @property mixed $message
* @property int $id
* @property int $appointment_id
* @property int $patient_id
* @property mixed $type
* @property mixed $prescription_code
* @property mixed $type_value
* @property mixed $type_value_total
* @property mixed $request_status
* @property mixed $qrcode_url
* @property mixed $prescription_date
* @property mixed $created_at
* @property mixed $updated_at
* @property object $appointment
* @property mixed $pdf
*/
class PrescriptionResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
private $code;
public function __construct($resource, $code = 200, $message = null)
{
parent::__construct($resource);
$this->code = $code;
$this->message = $message;
}
public function toArray($request)
{
return [
'code' => $this->code,
'message' => (isset($this->message)) ? [$this->message] : [__('digimed_validation.success_response.data_fetch_success')],
'data' => [
'id' => $this->id,
'appointment_id' => $this->appointment_id,
'patient_id' => $this->patient_id,
'type' => $this->type,
'prescription_code' => $this->prescription_code,
'type_value' => $this->type_value,
'type_value_total' => $this->type_value_total,
'status' => $this->request_status,
'pdf' => $this->pdf,
'qrcode_url' => $this->qrcode_url,
'prescription_date' => $this->prescription_date,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'patient_detail' => [
'id' =>$this->appointment->patientDetails->id,
'first_name' =>$this->appointment->patientDetails->first_name,
'last_name' =>$this->appointment->patientDetails->last_name,
'mobile_number' =>$this->appointment->patientDetails->mobile_number,
'profile_image' =>$this->appointment->patientDetails->profile_image,
'passport_number' => $this->appointment->patientDetails->passport_number,
'status' =>$this->appointment->patientDetails->status,
'avgratingdoctor' =>$this->appointment->patientDetails->avgratingdoctor,
'isfavourite' =>$this->appointment->patientDetails->isfavourite,
'patient_id' =>$this->appointment->patientDetails->unique_id,
],
'doctor_detail' => [
'id' =>$this->appointment->doctorDetails->id,
'first_name' =>$this->appointment->doctorDetails->first_name,
'last_name' =>$this->appointment->doctorDetails->last_name,
'mobile_number' =>$this->appointment->doctorDetails->mobile_number,
'profile_image' =>$this->appointment->doctorDetails->profile_image,
'passport_number' => $this->appointment->patientDetails->passport_number,
'status' =>$this->appointment->doctorDetails->status,
'avgratingdoctor' =>$this->appointment->doctorDetails->avgratingdoctor,
'isfavourite' =>$this->appointment->doctorDetails->isfavourite,
'specialist' => $this->appointment->doctorDetails->userDetail->UserAreaSpecialization,
],
'prescription_details' => (isset($this->PrescriptionDetails)) ? $this->PrescriptionDetails : (object) [],
'prescription_requests' => (isset($this->prescriptionRequests)) ? $this->prescriptionRequests : (object) [],
],
];
}
}