/** * Show the application dashboard to the user. * * @return Response */ public function index() { $doctor = Session::get('doctor'); $count = tickets::where('userid', Session::get('userid'))->count(); $countAppointment = doctorSchedule::where('uid', '=', Session::get('userid'))->count(); if (is_null($doctor)) { return view('user.userprofile')->with('user', Session::get('user'))->with('ticketCount', $count)->with('appointmentCount', $countAppointment); } else { return view('user.userprofile')->with('user', Session::get('user'))->with('doctor', $doctor)->with('ticketCount', $count)->with('appointmentCount', $countAppointment); } }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $wanted = user::where('id', $id)->first(); if (is_null($wanted)) { return "Not Found"; } else { $doctor = Doctor::where('email', '=', $wanted->email)->first(); $count = tickets::where('userid', $wanted->id)->count(); $countAppointment = doctorSchedule::where('uid', '=', $wanted->id)->count(); if (is_null($doctor)) { return view('user.profileview')->with('user', Session::get('user'))->with('viewing', $wanted)->with('ticketCount', $count)->with('appointmentCount', $countAppointment); } else { return view('user.profileview')->with('user', Session::get('user'))->with('viewing', $wanted)->with('doctor', $doctor)->with('ticketCount', $count)->with('appointmentCount', $countAppointment); } } }
/** * @param $day information regarding the schedule start/end time * @param $Cancel information regarding the canceled schedule start/end time * @param $periodMinutes Period of a schedule * @param $dt Datetime Object which contains the date of schedule * @param $doctor_id Id of the Doctor * * put time scedules into an array, filter Cancled timeslots and already reserved ones * @return array of schedules */ private function timeCal($day, $Cancel, $periodMinutes, $dt, $doctor_id) { // default start and end $startDefault = $dt->copy(); $endDefault = $dt->copy(); //canceling start and end $startCancel = $dt->copy(); $endCancel = $dt->copy(); //Default $startDefault->hour = $day[0]; $startDefault->minute = $day[1]; $endDefault->hour = $day[2]; $endDefault->minute = $day[3]; //canceling $startCancel->hour = $Cancel[0]; $startCancel->minute = $Cancel[1]; $endCancel->hour = $Cancel[2]; $endCancel->minute = $Cancel[3]; $times = array(); $timeval = array(); // returning array of the available time slots $twodArray = array(); // process default time while (floor($startDefault->diffInMinutes($endDefault, false) / $periodMinutes) > 0) { $con1 = floor($startDefault->diffInMinutes($startCancel, false) / $periodMinutes); $con2 = $startDefault->diffInMinutes($endCancel, false); // process cancel time if ($con1 <= 0 && $con2 > 0) { //echo '<br>herer'; $startDefault->hour = $endCancel->hour; $startDefault->minute = $endCancel->minute; } else { $schedules = doctorSchedule::where('did', '=', $doctor_id)->where('schedule_start', '=', $startDefault->toDateTimeString())->where('cancelUser', '=', 0)->where('cancelDoctor', '=', 0)->first(); if (is_null($schedules)) { $msg = $startDefault->format('h:i A') . "-" . $startDefault->copy()->addMinutes($periodMinutes)->format('h:i A'); array_push($times, $msg); $obj = (object) array('start' => $startDefault->toDateTimeString(), 'end' => $startDefault->copy()->addMinutes($periodMinutes)->toDateTimeString()); array_push($timeval, $obj); } $startDefault->addMinutes($periodMinutes); } } $twodArray['times'] = $times; $twodArray['vals'] = $timeval; return $twodArray; }
/** * Cancel Selected Appointment * * */ public function cancelAppointment($id) { doctorSchedule::where('id', $id)->update(['cancelDoctor' => '1']); $schedule = doctorSchedule::find($id); $currentDoctor = Doctor::find($schedule->did); $doctorName = $currentDoctor->first_name . ' ' . $currentDoctor->last_name; $currentUser = User::find($schedule->uid); Mail::send('mailtemplate/appointmentCancelled', ['name' => $currentUser->name, 'doctor' => $doctorName], function ($m) use($currentUser) { $m->from('*****@*****.**', 'Daemon'); $m->to($currentUser->email, $currentUser->name)->subject('Wedaduru Appointment Notice'); }); doctorSchedule::where('id', $value->id)->update(['cancelDoctor' => '1']); }