service_code)->first(); if ($serviceData) { $serviceName = $serviceData->name; } else { $serviceName = $this->service_cod; } if ($this->status == 'approved' && $this->status_final_log ){ $status = 'Done'; } else if ($this->status == 'declined' || $this->status_final_log == 'declined') { $status = 'Declined'; } else { $status = 'Ongoing'; } return [ 'id' => $this->id, 'admission_date' => $this->submission_date ?? null, 'discharge_date' => $this->discharge_date ?? null, 'code' => $this->code ?? null, 'service_type' => $serviceName, 'status' => $status, ]; } }