/**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create(Request $request)
 {
     $a = new schedule();
     $a->faculty_id = Auth::user()->id;
     $a->location = $request->location;
     $a->available_days = $request->availabledays;
     $a->available_time = $request->availabletiming;
     // dd($a);
     $a->save();
     return redirect('availability');
 }
示例#2
0
 public static function updateSchedule($diagDate, $diagTime, $mode, $doctorId)
 {
     $schedule = schedule::join('scheduleLog', 'schedule.scheduleLogId', '=', 'scheduleLog.scheduleLogId')->where('scheduleLog.doctorId', '=', $doctorId)->where('schedule.diagDate', '=', $diagDate)->where('schedule.diagTime', '=', $diagTime)->first();
     // add new schedule
     if ($schedule == null && $mode == 'true') {
         $slog = scheduleLog::newInstantScheduleLog($diagDate, $doctorId);
         $newSchedule = new schedule();
         $newSchedule->scheduleLogId = $slog->scheduleLogId;
         $newSchedule->diagDate = $diagDate;
         $newSchedule->diagTime = $diagTime;
         $newSchedule->save();
     } else {
         if ($schedule != null && $mode == 'false') {
             $appointments = $schedule->appointments()->get();
             foreach ($appointments as $app) {
                 $app->delete();
             }
             $schedule->delete();
         }
     }
 }