get('view_type', 'si'); $patientId = $request->get('patient_id'); $patientInfo = null; if ($viewType == 'si') { $patient = SttMedicalHistory::where('id', $id)->first(); $archiveJournal = ArchiveHistoryResource::collection($patient->archiveHistory); $archiveInfo = $patient->archiveInfo; if (!empty($archiveInfo)) { $archiveInfo = ArchiveInfoResource::make($patient->archiveInfo); } $patientInfo = [ 'info' => $patient, 'journal' => $archiveJournal, 'archiveInfo' => $archiveInfo, ]; } return response()->json($patientInfo); } }