get('view_type', 'mis'); $patientId = $request->get('patient_id'); $archiveInfo = ArchiveInfo::whereId($id)->first()->load('status'); if ($viewType == 'foxpro') $patient = $archiveInfo->foxproHistory; else $patient = $archiveInfo->misHistory; $archiveJournal = $patient->archiveHistory ? ArchiveHistoryResource::collection($patient->archiveHistory) : null; // dd($archiveInfo); if (!empty($archiveInfo)) { $archiveInfo = ArchiveInfoResource::make($archiveInfo)->toArray(request()); } else { $archiveInfo = null; } $patientInfo = [ 'historyable_type' => $viewType == 'foxpro' ? SiSttMedicalHistory::class : MisSttMedicalHistory::class, 'info' => [ 'historyable_type' => $viewType == 'foxpro' ? SiSttMedicalHistory::class : MisSttMedicalHistory::class, ...PatientInfoResource::make($patient)->toArray(request()), 'can_be_issued' => $patient->canBeIssued() ], 'journal' => $archiveJournal, 'archiveInfo' => $archiveInfo ]; return response()->json($patientInfo); } }