list dan show appointment
This commit is contained in:
45
Modules/Internal/Transformers/AppointmentResource.php
Normal file
45
Modules/Internal/Transformers/AppointmentResource.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Internal\Transformers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class AppointmentResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$appointment = [
|
||||
'id' => $this->nID,
|
||||
'doctor_name' => isset($this->doctor->user->sFirstName) ? $this->doctor->user->sFirstName . ' ' . $this->doctor->user->sLastName : null,
|
||||
'speciality' => $this->doctor->speciality->sKeterangan,
|
||||
'date_appointment' => Carbon::parse($this->appointmentDetail->dTanggalAppointment)->format('d-m-Y') . ' ' . $this->appointmentDetail->tTimeAppointment,
|
||||
'date_created' => Carbon::parse($this->dCreateOn)->format('d-m-Y H:i:s') ?? null,
|
||||
'appointment_media' => $this->sMedia,
|
||||
'status' => $this->status_name,
|
||||
'health_care' => $this->healthCare->sHealthCare ?? null,
|
||||
'payment_method' => $this->payment_method ?? null,
|
||||
];
|
||||
|
||||
$payment_detail = null;
|
||||
if ($this->appointmentDetail->sPaymentDetails != null) {
|
||||
$payment_detail = [
|
||||
'payment_type' => $this->appointmentDetail->sPaymentDetails['payment_type'],
|
||||
'transaction_time' => $this->appointmentDetail->sPaymentDetails['transaction_time'],
|
||||
'gross_amount' => $this->appointmentDetail->sPaymentDetails['gross_amount'],
|
||||
'currency' => $this->appointmentDetail->sPaymentDetails['currency'],
|
||||
'status_message' => $this->appointmentDetail->sPaymentDetails['status_message'],
|
||||
];
|
||||
}
|
||||
|
||||
$appointment['payment_detail'] = $payment_detail;
|
||||
|
||||
return $appointment;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user