title: Laravel add custom middleware to route group
body: <p>in my web application i have admin panel and i'm trying to make access to users that they have admin role by this code:</p>
  
  <pre><code>namespace App\Http\Middleware;
  use Closure;
  class CheckUserAdminRole
  {
      public function handle($request, Closure $next)
      {
          if (auth()-&gt;check()) {
              if (auth()-&gt;check() &amp;&amp; !auth()-&gt;user()-&gt;hasRole('admin')) {
                  auth()-&gt;logout();
                  return redirect(route('system.messages','userIsNotAdmin'));
              }
          }
          return $next($request);
      }
  }
  </code></pre>
  
  <p>and in my routs i have this route group:</p>
  
  <pre><code>Route::group(['namespace' =&gt; 'Dashboard', 'middleware' =&gt; ['auth:web'], 'prefix' =&gt; 'dashboard'], function () {
      $this-&gt;group(['prefix' =&gt; 'administrator'], function () {
          $this-&gt;get('panel', 'AdminController@index');
  });
  </code></pre>
  
  <p>my kernel:</p>
  
  <pre><code>protected $middleware = [
      \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
      \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
      ...
      \App\Http\Middleware\CheckUserAdminRole::class,
  ];
  </code></pre>
  
  <p>now when i add my middleware as <code>CheckUserAdminRole</code> to route group like with this code:</p>
  
  <pre><code>Route::group(['namespace' =&gt; 'Dashboard', 'middleware' =&gt; ['auth:web','CheckUserAdminRole'], 'prefix' =&gt; 'dashboard'], function () {
  </code></pre>
  
  <p>i get this error:</p>
  
  <pre><code>Class CheckUserAdminRole does not exist
  </code></pre>
  
  <p>this codes couldn't resolve my problem:</p>
  
  <pre><code>php artisan route:clear
  php artisan cache:clear
  php artisan config:clear
  composer dump-autoload
  </code></pre>