report livechat

This commit is contained in:
Linksehat Staging Server
2023-08-31 16:39:03 +07:00
parent 26b82db77b
commit e0f3a38be0
4 changed files with 29 additions and 8 deletions

View File

@@ -15,14 +15,24 @@ class LivechatController extends Controller
* Display a listing of the resource.
* @return Renderable
*/
public function index()
public function index(Request $request)
{
$startDate = '2023-01-01';
$endDate = '2023-08-01';
$livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare')
->where('nIDAppointment', '!=', null)->where('nIDAppointment', '!=', '');
$startDate = $request->startDate;
$endDate = $request->endDate;
$livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare')
->where('nIDAppointment', '!=', null)
->where('nIDAppointment', '!=', '');
if ($startDate){
$livechat = $livechat->where('dCreateOn', '>=', $startDate);
}
if ($endDate){
$livechat = $livechat->where('dCreateOn', '<=', $endDate);
}
$livechat = $livechat->latest()->paginate(15);
return response()->json(Helper::paginateResources(LivechatResource::collection($livechat)));

View File

@@ -18,11 +18,14 @@ class LivechatResource extends JsonResource
$livechat = [
'id' => $this->nID,
'doctor_name' => isset($this->doctor->user->sFirstName) ? $this->doctor->user->sFirstName . ' ' . $this->doctor->user->sLastName : null,
'pasien_name' => isset($this->user->sFirstName) ? $this->user->sFirstName . ' ' . $this->user->sLastName : null,
'pasien_phone' => isset($this->user->sPhone) ? $this->user->sPhone : '-',
'pasien_email' => isset($this->user->sEmail) ? $this->user->sEmail : '-',
'speciality' => $this->doctor->speciality->sKeterangan ?? null,
'health_care' => $this->healthCare->sHealthCare ?? null,
'date_appointment' => Carbon::parse($this->appointment->appointmentDetail->dTanggalAppointment)->format('d-m-Y')
. ' ' . $this->appointment->appointmentDetail->tTimeAppointment ?? null,
'status_appointment' => $this->appointment->status_name ?? null,
'status_appointment' => $this->appointment->paymentStatus ?? null,
'date_created' => Carbon::parse($this->appointment->dCreateOn)->format('d-m-Y H:i:s') ?? null,
'patient_media' => $this->sMedia ?? null,
'doctor_media' => $this->sMediaDokter ?? null,