/**
  * @Get("horario")
  */
 public function showSchedule()
 {
     $aWeek = array('M' => 1, 'T' => 2, 'W' => 3, 'Tu' => 4, 'F' => 5, 'S' => 6, 'Su' => 7);
     $aOcuppied = array();
     $days = array(1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => "", 7 => "");
     $schedule = Schedule::where('active', 1)->get()->first();
     $events = ClaseSchedule::where('schedule_id', $schedule->id)->orderBy('date')->orderBy('startTime')->get();
     foreach ($events as $event) {
         $todayWeek = date('N');
         $reserveDay = $aWeek[$event->date];
         $daysBetween = $this->subtractDate($todayWeek, $reserveDay);
         $reserveDate = date('Y-m-d', strtotime("now + " . $daysBetween . " day"));
         $placesOcuppied = Reserve::where('reserve_day', $reserveDate)->where('event_id', $event->id)->count();
         $aOcuppied[$event->date][$event->id] = $event->capMax - $placesOcuppied;
         if ($days[$aWeek[$event->date]] == "") {
             $dateExplode = explode('-', $reserveDate);
             $days[$aWeek[$event->date]] = $dateExplode[2] . "/" . $dateExplode[1] . "/" . $dateExplode[0];
         }
     }
     // foreach ($days as $key => $value) {
     //     if($value == "")
     //         $days[$key] = date('Y-m-d', strtotime($days[($key-1 == 0)?7:$key-1]." + 1 day"));
     // }
     return view('schedule.viewSchedule', ['schedule' => $schedule, 'clases' => Clase::lists('name', 'id'), 'schedules' => Schedule::lists('name', 'id'), 'rooms' => Room::lists('name', 'id'), 'instructors' => User::where('type_id', 2)->lists('name', 'id'), 'places' => $aOcuppied, 'events' => $events, 'days' => $days]);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @Delete("user/type/delete/{id}")
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroyType($id)
 {
     $usersToDelete = [];
     $users = User::where('type_id', $id)->get();
     //We retrieve all users which have the type that we want to delete
     foreach ($users as $user) {
         $usersToDelete[] = $user->id;
         //We store the users id to delete
     }
     User::destroy($usersToDelete);
     //We delete those users. We need delete them before becouse users have a foreign key (type_id)
     Type::destroy($id);
     Session::flash('message', 'Tipo Eliminado Correctamente');
     return Redirect::to('/user/type');
 }
 /**
  * @Get("/reservas/nueva")
  */
 public function create()
 {
     $schedule = Schedule::where('active', 1)->first();
     return view("schedule.reserveCreate", ['section' => 'reserve', 'subsection' => 'create', 'users' => User::where('type_id', 3)->get(), 'events' => ClaseSchedule::where('schedule_id', $schedule->id)->get()]);
 }