コード例 #1
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();
});
コード例 #2
0
ファイル: TimeslotController.php プロジェクト: AUCSC/sac
 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'));
 }
コード例 #3
0
ファイル: routes.php プロジェクト: morph07/lead-scheduler
    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"];
    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;
コード例 #4
0
ファイル: RoomsController.php プロジェクト: oredla/p4
 /**
  * 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');
     }
 }
コード例 #5
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;
 }