Beispiel #1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!UserRepository::hasRole('admin', $this->auth->user())) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect('/');
         }
     }
     return $next($request);
 }
Beispiel #2
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $airline = Airline::find(Session::get('airlineId'));
     if (!UserRepository::hasRole($airline->prefix . '-staff', $this->auth->user())) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect('/');
         }
     }
     return $next($request);
 }
Beispiel #3
0
 /**
  * Bind data to the view.
  *
  * @param  View  $view
  * @return void
  */
 public function compose(View $view)
 {
     // Are we connecting from a known URL?
     if ($airline = Airline::where('url', '=', Request::getHttpHost())->first()) {
         Session::put('airlineId', $airline->id);
     }
     if (Session::has('airlineId')) {
         $view->with('airline', Airline::find(Session::get('airlineId')));
     }
     if (Request::user()) {
         $view->with('user', Request::user());
         $view->with('pilot', PilotRepository::getCurrentPilot());
         $airline = Airline::find(Session::get('airlineId'));
         $view->with('airlineStaff', UserRepository::hasRole($airline->prefix . '-staff', Request::user()));
     }
 }