Beispiel #1
0
 private function getEventsForRoom($roomNumber)
 {
     $roomInfo = CeasRooms::where('name', '=', $roomNumber)->first();
     if ($roomInfo !== null) {
         switch ($roomInfo->type) {
             case 1:
                 $events = Classroom::where('RoomId', '=', $roomInfo->id)->get();
                 break;
             case 2:
                 $events = ComputerClassroom::where('RoomId', '=', $roomInfo->id)->get();
                 break;
             case 3:
                 $events = BreakoutRoom::where('RoomId', '=', $roomInfo->id)->get();
                 break;
             case 4:
                 $events = SpecialRoom::where('RoomId', '=', $roomInfo->id)->get();
                 break;
             default:
                 $events = array();
                 break;
         }
         return $events;
     } else {
         return array();
     }
 }
 public function deleteDestroy()
 {
     $modelArray = array();
     $deleteModels = Input::json('models');
     foreach ($deleteModels as $model) {
         $deleteComputerClassroom = ComputerClassroom::find($model['id']);
         $deleteComputerClassroom->delete();
         array_push($modelArray, $deleteComputerClassroom);
         $returnModels = BaseCollection::make($modelArray);
     }
     echo $returnModels->toJson();
 }
Beispiel #3
0
 public function deleteEvents()
 {
     $input = Input::all();
     $semester = Semester::find($input['semester']);
     switch ($input['roomType']) {
         case 'Classroom':
             $events = Classroom::where('Start', '>', $semester->start_date)->where('End', '<', $semester->end_date)->get();
             break;
         case 'Breakout':
             $events = BreakoutRoom::where('Start', '>', $semester->start_date)->where('End', '<', $semester->end_date)->get();
             break;
         case 'Computer':
             $events = ComputerClassroom::where('Start', '>', $semester->start_date)->where('End', '<', $semester->end_date)->get();
             break;
         case 'Special':
             $events = SpecialRoom::where('Start', '>', $semester->start_date)->where('End', '<', $semester->end_date)->get();
             break;
     }
     foreach ($events as $event) {
         $event->delete();
     }
 }
 private function checkDuplicates($modelToBeAdded, $table)
 {
     switch ($table) {
         case "Classrooms":
             $existingModel = Classroom::where('title', '=', $modelToBeAdded->title)->where('Start', '=', $modelToBeAdded->Start)->where('End', '=', $modelToBeAdded->End) - get();
             break;
         case "Breakout Rooms":
             $existingModel = BreakoutRoom::where('title', '=', $modelToBeAdded->title)->where('Start', '=', $modelToBeAdded->Start)->where('End', '=', $modelToBeAdded->End) - get();
             break;
         case "Computer Classrooms":
             $existingModel = ComputerClassroom::where('title', '=', $modelToBeAdded->title)->where('Start', '=', $modelToBeAdded->Start)->where('End', '=', $modelToBeAdded->End) - get();
             break;
         case "Special Rooms":
             $existingModel = SpecialRoom::where('title', '=', $modelToBeAdded->title)->where('Start', '=', $modelToBeAdded->Start)->where('End', '=', $modelToBeAdded->End) - get();
             break;
     }
     if ($existingModel != '[]') {
         return $existingModel;
     } else {
         return false;
     }
 }