コード例 #1
0
ファイル: TimeslotsController.php プロジェクト: oredla/p4
 /**
  * Responds to requests to POST /timeslots/create
  */
 public function postCreate(Request $request)
 {
     $this->validate($request, ['inputRoomID' => 'required', 'inputAvailableFrom' => 'required', 'inputAvailableUntil' => 'required']);
     $timeslot = new \App\Timeslot();
     $timeslot->room_id = $request->inputRoomID;
     $timeslot->available_from = $request->inputAvailableFrom;
     $timeslot->available_until = $request->inputAvailableUntil;
     $timeslot->available_weekdays = $request->inputSun + $request->inputMon + $request->inputTue + $request->inputWed + $request->inputThu + $request->inputFri + $request->inputSat;
     $timeslot->save();
     \Session::flash('flash_message', 'New timeslot has been added.');
     return redirect('/timeslots');
 }
コード例 #2
0
ファイル: routes.php プロジェクト: morph07/lead-scheduler
});
Route::resource('note', 'NoteController', ['only' => 'store']);
Route::bind('doctor', function ($id) {
    return App\Doctor::whereId($id)->first();
});
Route::resource('doctor', 'DoctorController');
Route::bind('user', function ($id) {
    return App\User::whereId($id)->first();
});
Route::resource('user', 'UserController');
Route::bind('location', function ($id) {
    return App\Location::whereId($id)->first();
});
Route::resource('location', 'LocationController');
Route::bind('timeslot', function ($id) {
    return App\Timeslot::whereId($id)->first();
});
Route::resource('timeslot', 'TimeslotController');
Route::get('{lead_id}/retrieve_notes', ['as' => 'retrieve_notes_by_lead', 'uses' => 'NoteController@retrieveNote']);
//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"];