public function showAll() { $user = Confide::user(); $patients = Patient::join('user', 'user.id', '=', 'patient.user_id')->get(); if ($user->isStaff()) { return View::make('home.patient.show-all', compact('user', 'patients')); } else { return Redirect::route('home.index'); } }
public function showAll($requestID = null) { $user = Confide::user(); $patient = Patient::find($requestID); $patient = Patient::join('user', 'user.id', '=', 'patient.user_id')->where('patient.user_id', '=', $user->id)->first(); if ($user->isStaff() && $requestID !== null) { // If weare requesting a patient's appointments and we are Staff $appointments = Appointment::where('patient_id', '=', $requestID)->get(); $patient = Patient::join('user', 'user.id', '=', 'patient.user_id')->where('patient.user_id', '=', $requestID)->first(); } else { $appointments = Appointment::where('patient_id', '=', $user->id)->get(); } foreach ($appointments as $appointment) { $doctor = User::find($appointment->staff_id); $appointment->doctor = $doctor->first_name . ' ' . $doctor->last_name; } return View::make('home/appointment/show-all', compact('user', 'appointments', 'patient')); }