Пример #1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // return $next($request);
     if (auth::check()) {
         return $next($request);
     } else {
         return Redirect::to('login');
     }
 }
Пример #2
0
 public function __construct()
 {
     $userRole = "Unknown User";
     if (auth::check()) {
         switch (session()->get('user_role')) {
             case "customer":
                 $userRole = "Customer";
                 break;
             case "admin":
                 $userRole = "Administrator";
                 break;
             case "event-planner":
                 $userRole = "Event Planner";
                 break;
             case "team-member":
                 $userRole = "Team Member";
                 break;
             default:
                 switch (Auth::User()->role) {
                     case "customer":
                         $userRole = "Customer";
                         break;
                     case "admin":
                         $userRole = "Administrator";
                         break;
                     case "event-planner":
                         $userRole = "Event Planner";
                         break;
                     case "team-member":
                         $userRole = "Team Member";
                         break;
                     default:
                         $userRole = "Unknown User";
                 }
         }
     } else {
         return redirect()->guest('login');
     }
     View::share('userRole', $userRole);
 }