Example #1
0
 public function postNew()
 {
     $NewModel = Input::json('models.0');
     $startDatetime = new DateTime();
     $endDatetime = new DateTime();
     $Eastern = new DateTimeZone('America/Detroit');
     $startDatetime->setTimezone($Eastern);
     $endDatetime->setTimezone($Eastern);
     $startDatetime->setTimestamp(strtotime($NewModel['Start']));
     $endDatetime->setTimestamp(strtotime($NewModel['End']));
     $newClassroom = new Classroom();
     $newClassroom->RoomId = $NewModel['RoomId'];
     $newClassroom->Title = $NewModel['Title'];
     $newClassroom->Start = $startDatetime->format('Y-m-d H:i:s');
     $newClassroom->End = $endDatetime->format('Y-m-d H:i:s');
     $newClassroom->Attendee = $NewModel['Attendee'];
     $newClassroom->Host = $NewModel['Host'];
     $newClassroom->RecurrenceId = $NewModel['RecurrenceId'];
     if (array_key_exists('RecurrenceRule', $NewModel)) {
         $newClassroom->RecurrenceRule = $NewModel['RecurrenceRule'];
     }
     $newClassroom->RecurrenceException = $NewModel['RecurrenceException'];
     $newClassroom->save();
     return $newClassroom->toJson();
 }