public function reportPage($id) { $report = Reports::find($id); if ($report) { $recommendation = Recommendation::where('report_id', $report->id)->join('users', 'users.id', '=', 'recommendations.doctor_id')->first(); $conversations = Conversation::where('report_id', $report->id)->where('patient_id', auth()->user()->id)->get(); $data = ['report' => $report, 'recommendation' => $recommendation, 'conversations' => $conversations]; return view('frontend.user.report_page', $data); } else { abort(404); } }
public function referPatient($id, ReferPatientRequest $request) { if ($report = Reports::find($id)) { $report->assigned_doctor_id = $request->doctors; $report->save(); $newDocAss = new PatientAssignment(); $newDocAss->doctor_id = $request->doctors; $newDocAss->patient_id = $report->user_id; $newDocAss->report_id = $report->id; $newDocAss->save(); return redirect('doctor/dashboard')->withFlashSuccess("The patient <strong>({$report->patient_name})</strong> has been referred appropriately "); } else { abort(404); } }