示例#1
0
 public static function updateSlots($start_time, $end_time, $day_id)
 {
     $fifteen_mins = 15 * 60;
     $start = strtotime($start_time);
     $end = strtotime($end_time);
     Timeslot::where('dutyday_id', '=', $day_id)->delete();
     while ($start <= $end) {
         $timeslot = new Timeslot();
         $timeslot->slot = date("H:i:s", $start);
         $timeslot->save();
         $timeslot->dutyday_id = $day_id;
         $timeslot->save();
         $start += $fifteen_mins;
     }
 }
 public function getFreeSlots()
 {
     $id = Input::get('id');
     // Get Employee id
     $date = Input::get('date');
     // Get selected date
     $day = date('l', strtotime($date));
     // Get day name from date
     $duty_day = Dutyday::where('employee_id', $id)->where('day', $day)->get()->first();
     if ($duty_day) {
         $slot = null;
         $appointments = Appointment::where('date', $date)->where('employee_id', $id)->get();
         if (count($appointments) > 0) {
             $timeslots = Timeslot::where('dutyday_id', $duty_day->id)->where('employee_id', $id);
             foreach ($appointments as $appointment) {
                 $slot = $timeslots->where('slot', '!=', $appointment->time)->get()->toJson();
             }
         } else {
             $slot = Timeslot::where('dutyday_id', $duty_day->id)->get()->toJson();
         }
         return JsonResponse::create($slot);
     }
     return 'false';
 }