original_string: public function handle(Request $request, Closure $next, $roles)
      {
          $accessDenied = true;
  
          if (!$user = $this->auth->getActiveUser()) {
              Flash::error(trans('dashboard::dashboard.flash.access_denied'));
  
              return redirect()->route('auth.login');
          }
  
          if (!is_array($roles)) {
              $roles = [$roles];
          }
  
          foreach ($roles as $role) {
  
              if (!$role = $this->role->getBySlug($role)) {
                  continue;
              }
  
              if ($user->inRole($role)) {
                  $accessDenied = false;
              }
          }
  
          if ($accessDenied) {
              Flash::error(trans('dashboard::dashboard.flash.access_denied'));
  
              // Redirect back to the previous page where request was made.
              return redirect()->back();
          }
  
          return $next($request);
      }
code: public function handle(Request $request, Closure $next, $roles)
      {
          $accessDenied = true;
  
          if (!$user = $this->auth->getActiveUser()) {
              Flash::error(trans('dashboard::dashboard.flash.access_denied'));
  
              return redirect()->route('auth.login');
          }
  
          if (!is_array($roles)) {
              $roles = [$roles];
          }
  
          foreach ($roles as $role) {
  
              if (!$role = $this->role->getBySlug($role)) {
                  continue;
              }
  
              if ($user->inRole($role)) {
                  $accessDenied = false;
              }
          }
  
          if ($accessDenied) {
              Flash::error(trans('dashboard::dashboard.flash.access_denied'));
  
              // Redirect back to the previous page where request was made.
              return redirect()->back();
          }
  
          return $next($request);
      }
code_tokens: public function handle ( Request $ request , Closure $ next , $ roles ) { $ accessDenied = true ; if ( ! $ user = $ this -> auth -> getActiveUser ( ) ) { Flash :: error ( trans ( 'dashboard::dashboard.flash.access_denied' ) ) ; return redirect ( ) -> route ( 'auth.login' ) ; } if ( ! is_array ( $ roles ) ) { $ roles = [ $ roles ] ; } foreach ( $ roles as $ role ) { if ( ! $ role = $ this -> role -> getBySlug ( $ role ) ) { continue ; } if ( $ user -> inRole ( $ role ) ) { $ accessDenied = false ; } } if ( $ accessDenied ) { Flash :: error ( trans ( 'dashboard::dashboard.flash.access_denied' ) ) ; // Redirect back to the previous page where request was made. return redirect ( ) -> back ( ) ; } return $ next ( $ request ) ; }
docstring: Check if user belongs to the specified role.
  
  @param Request      $request
  @param Closure      $next
  @param string|array $roles
  
  @return \Illuminate\Http\RedirectResponse
docstring_tokens: Check if user belongs to the specified role .