Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(StoreTimeslotRequest $request)
 {
     foreach ($request->time as $time) {
         $timeslot = new Timeslot();
         $timeslot->location_id = $request->location_id;
         $timeslot->day = $request->day;
         $timeslot->time = $time;
         $timeslot->save();
     }
     return redirect()->back()->with('message', 'Timeslot added.');
 }
 /**
  * Execute the job.
  * @return Timeslot
  * @throws ModelAlreadyExistsException
  */
 public function handle()
 {
     $timeslot = new Timeslot();
     $timeslot->fill(['day_id' => $this->day->id, 'begin' => $this->formatDate($this->begin), 'end' => $this->formatDate($this->end)]);
     $validator = new TimeslotValidator();
     if (!$validator->exists($timeslot)) {
         throw new ModelAlreadyExistsException('Dit timeslot bestaat al.');
     }
     $timeslot->save();
     $timeslot->rooms()->sync($this->rooms->pluck('id')->toArray());
     return $timeslot->fresh(['rooms', 'day']);
 }
 public function exists(Timeslot $timeslot)
 {
     return $timeslot->query()->where(['day_id' => $timeslot->day_id, 'begin' => $timeslot->begin, 'end' => $timeslot->end])->get(['id'])->count() == 0;
 }
Exemplo n.º 4
0
 /**
  * Responds to requests to POST /timeslots/delete/
  */
 public function postDoDelete(Request $request)
 {
     $this->validate($request, ['delete_id' => 'required|integer']);
     $user = \Auth::user();
     $delete_timeslot = \App\Timeslot::find($request->delete_id);
     if ($user->user_role == 'admin') {
         $delete_timeslot->delete();
         \Session::flash('flash_message', 'Timeslot has been deleted.');
         return redirect('/timeslots');
     } else {
         \Session::flash('flash_message', 'You don't have the previlege to delete this room.');
         return redirect('/timeslots');
     }
 }
Exemplo n.º 5
0
use App\Http\Controllers\RoomsController;
use App\Http\Controllers\TimeslotsController;
use App\Room;
use App\Timeslot;
Route::model('room', 'App\\Room');
Route::get('/', function () {
    return view('welcome');
});
Route::get('/home', HomeController::class . '@index');
Route::get('/week', function () {
    return View::make('control-pages.week', ['rooms' => Room::all()]);
});
Route::resource('room', RoomsController::class);
Route::resource('timeslot', TimeslotsController::class);
Route::get('/api/week', function () {
    return ['Maandag' => Timeslot::where('day_id', '1')->orderBy('begin')->get(), 'Dinsdag' => Timeslot::where('day_id', '2')->orderBy('begin')->get(), 'Woensdag' => Timeslot::where('day_id', '3')->orderBy('begin')->get(), 'Donderdag' => Timeslot::where('day_id', '4')->orderBy('begin')->get(), 'Vrijdag' => Timeslot::where('day_id', '5')->orderBy('begin')->get(), 'Zaterdag' => Timeslot::where('day_id', '6')->orderBy('begin')->get(), 'Zondag' => Timeslot::where('day_id', '7')->orderBy('begin')->get()];
});
Route::get('/api/week/{room}', function (Room $room) {
    $days_list = \App\Day::all();
    $days = [];
    foreach ($days_list as $day) {
        $days[$day->day] = [];
    }
    foreach ($room->timeslots as $timeslot) {
        $days[$timeslot->day->day][] = $timeslot;
    }
    return $days;
});
Route::get('/api/rooms', function () {
    return \App\Room::with('timeslots')->get();
});
Exemplo n.º 6
0
 public function preview()
 {
     $rooms = Room::where("available", true)->get();
     $days = Timeslot::orderBy("id", 'desc')->first()->day;
     $presentations = Presentation::where('conference_id', '=', get_current_conference_id())->whereNotNull('timeslot')->get();
     $timeslots = Timeslot::where('conference_id', '=', get_current_conference_id())->get();
     return view('timeslots.preview', compact('timeslots', 'rooms', 'presentations', 'days'));
 }
Exemplo n.º 7
0
 /**
  * Responds to requests to POST /rooms/delete/
  */
 public function postDoDelete(Request $request)
 {
     $this->validate($request, ['delete_id' => 'required|integer']);
     $user = \Auth::user();
     $delete_room = \App\Room::find($request->delete_id);
     $reservations = \App\Reservation::where('room_id', $delete_room->id)->get();
     $timeslots = \App\Timeslot::where('room_id', $delete_room->id)->get();
     if ($user->user_role == 'admin') {
         foreach ($reservations as $reservation) {
             $reservation->delete();
         }
         foreach ($timeslots as $timeslot) {
             $timeslot->delete();
         }
         $delete_room->delete();
         \Session::flash('flash_message', $delete_room->room_name . ' has been deleted.');
         return redirect('/rooms');
     } else {
         \Session::flash('flash_message', 'You don't have the previlege to delete this room.');
         return redirect('/rooms');
     }
 }
Exemplo n.º 8
0
 public function store(Request $request)
 {
     if (Room::count() == 0) {
         flash()->error("You must add at least one room before creating\n                      a conference");
         return back()->withInput();
     }
     $this->validate($request, ['name' => 'required|min:5|max:255']);
     $first = $request['start_time'];
     $last = $request['end_time'];
     if (empty($first[0]) or empty($last[0])) {
         flash()->error("You must add a start time and an end time");
         return back()->withInput();
     }
     $conference = new Conference();
     $conference->name = $request['name'];
     $conference->save();
     $rooms = Room::where('available', true)->get();
     $numDays = sizeOf($first);
     //start day loop from here
     if ($numDays == 1) {
         $times = [];
         $tStart = strtotime($first[0]);
         $tEnd = strtotime($last[0]);
         $tNow = $tStart;
         $i = 1;
         $times[0] = date("H:i", $tNow) . "\n";
         while ($tNow < $tEnd) {
             $tNow = strtotime('+30 minutes', $tNow);
             $times[$i] = date("H:i", $tNow) . "\n";
             $i = $i + 1;
         }
         foreach ($rooms as $room) {
             foreach ($times as $time) {
                 $timeslot = new Timeslot();
                 $timeslot->day = 1;
                 $timeslot->room_code = $room->code;
                 $timeslot->conference_id = $conference->id;
                 $timeslot->time = $time;
                 $timeslot->save();
             }
         }
     } else {
         for ($day = 1, $index = 0; $day < $numDays || $index < $numDays - 1; $day++, $index++) {
             $times = [];
             $tStart = strtotime($first[$index]);
             $tEnd = strtotime($last[$index]);
             $tNow = $tStart;
             $i = 1;
             $times[0] = date("H:i", $tNow) . "\n";
             while ($tNow < $tEnd) {
                 $tNow = strtotime('+30 minutes', $tNow);
                 $times[$i] = date("H:i", $tNow) . "\n";
                 $i = $i + 1;
             }
             //$i os the number of timeslots
             foreach ($rooms as $room) {
                 foreach ($times as $time) {
                     $timeslot = new Timeslot();
                     $timeslot->day = $day;
                     $timeslot->room_code = $room->code;
                     $timeslot->conference_id = $conference->id;
                     $timeslot->time = $time;
                     $timeslot->save();
                 }
             }
         }
     }
     flash()->success("New conference created successfully!!");
     return redirect()->route('user.show');
 }
Exemplo n.º 9
0
//get available timeslot locations
Route::get('timeslot/available/{location_id}/{day}', function ($location_id, $day) {
    $timeslots = array('00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00');
    $selectedTimeslots = \App\Timeslot::where('location_id', $location_id)->where('day', $day)->lists('time')->toArray();
    return array_diff($timeslots, $selectedTimeslots);
});
Route::get('doctor/{doctor}/available-locations', function ($doctor) {
    return $doctor->locations;
});
Route::get('timeslot/{location_id}/daysofweek', function ($location_id) {
    $daysOfWeek = \App\Timeslot::select('day')->where('location_id', $location_id)->groupBy('day')->lists('day')->toArray();
    $fullDaysOfWeek = ["0", "1", "2", "3", "4", "5", "6"];
    return array_diff($fullDaysOfWeek, $daysOfWeek);
});
Route::get('timeslot/location/{location_id}/dayofweek/{day}', function ($location_id, $day) {
    $timeslots = \App\Timeslot::select('time')->where('location_id', $location_id)->where('day', $day)->lists('time');
    return $timeslots;
});
use App\LeadUnload;
// set lead active to 0
Route::get('lead/{lead}/inactive', function ($lead) {
    $lead->active = 0;
    $lead->save();
    // send pusher event
    event(new LeadUnload($lead));
    return 'done';
});
Route::get('{lead_id}/retrieve_notes', ['as' => 'retrieve_notes_by_lead', 'uses' => 'NoteController@retrieveNote']);
get('{lead_id}/disposition_history', ['as' => 'disposition_lead_history', 'uses' => 'LeadController@getDispositionHistory']);
get('leads/success', ['as' => 'success_leads', 'uses' => 'LeadController@getSuccessLeads']);
get('patient/{query}', function ($query) {
 /**
  * Remove the specified resource from storage.
  *
  * @param Timeslot $timeslot
  * @return \Illuminate\Http\Response
  * @throws \Exception
  */
 public function destroy(Timeslot $timeslot)
 {
     $timeslot->delete();
     return redirect('/week');
 }
Exemplo n.º 11
0
 public function saveClass($topic_id, $teacher_id, $timeslots, $demo = false)
 {
     $session = new \App\Session();
     $session->topic_id = $topic_id;
     $session->teacher_id = $teacher_id;
     $session->student_id = Auth::user()->deriveable->id;
     $session->demo = $demo ? 1 : 0;
     $session->save();
     foreach ($timeslots as $key => $value) {
         \App\Timeslot::where('teacher_id', $teacher_id)->where('slot', $value)->update(['session_id' => $session->id]);
     }
     return $session;
 }