Ejemplo n.º 1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (Auth::user()->role == 'admin') {
         $reservations = Reservation::orderBy('check_in')->paginate(15);
     } elseif (Auth::user()->role == 'user') {
         $reservations = Auth::user()->reservations()->paginate(15);
     }
     return view('reservation.index', compact('reservations'));
 }
Ejemplo n.º 2
0
 /**
  * Responds to requests to GET /reservation/{reservation_id?}
  */
 public function getMyView($reservation_id)
 {
     $user = \Auth::user();
     if ($user->user_role == 'admin' || $user->id == $reservation_id) {
         $reservations = \App\Reservation::orderBy('date_of_event', 'ASC')->orderBy('start_time', 'ASC')->orderBy('room_id', 'ASC')->where('user_id', '=', $reservation_id)->with('room')->get();
         return view('reservations.mylist')->with('reservations', $reservations);
     } else {
         \Session::flash('flash_message', 'You do not have access to other people's pending reservations.');
         return redirect('/reservations');
     }
 }
Ejemplo n.º 3
0
 public function listeRes()
 {
     $res = Reservation::orderBy('updated_at', 'desc')->take(50)->get();
     return view('admin.listeRes')->with(['reservations' => $res]);
 }
Ejemplo n.º 4
0
Archivo: routes.php Proyecto: oredla/p4
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
//dashboard
Route::get('/', function () {
    if (\Auth::check()) {
        $user = \Auth::user();
        $reservations = \App\Reservation::orderBy('date_of_event', 'ASC')->orderBy('start_time', 'ASC')->orderBy('room_id', 'ASC')->where('user_id', '=', $user->id)->with('room')->get();
        return view('welcome')->with('reservations', $reservations);
    } else {
        return view('welcome');
    }
});
// *****************************************************************************
// User Profile and Management routes
// *****************************************************************************
Route::group(['middleware' => 'auth'], function () {
    Route::get('/user', 'UsersController@getUser');
    Route::get('/user/create', 'UsersController@getCreate');
    Route::get('/user/edit', 'UsersController@getUserEdit');
    Route::get('/user/edit/password', 'UsersController@getUserPassword');
    Route::get('/user/confirm-delete/{user_id?}', 'UsersController@getConfirmDelete');
    Route::post('/user/create', 'UsersController@postCreate');