Laravel RoleMiddleware, class role not found
<p>I'm trying to add a simple middleware to check if a user matches a role.  I'm running into an issue when I use the middleware, I get an Exception:</p>

<blockquote>
  <p>ReflectionException: class role does not exist</p>
</blockquote>

<p>I do not attempt to call a class named role so I assume this is happening magically in Laravel somewhere.</p>

<p>My middleware:</p>

<pre><code>class RoleMiddleware
{
    /**
     * Run the request filter.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @param  string  $role
     * @return mixed
     */
    public function handle($request, Closure $next, $role)
    {
        if (! $request-&gt;user()-&gt;is($role)) {
            return redirect('/login');
        }

        return $next($request);
    }

}
</code></pre>

<p>In the users table, I have a role field and in the User model I have:</p>

<pre><code>/**
 * Check if a user is a certain role
 *
 * @param $role
 * @return bool
 */
function is($role) {
    return ($this-&gt;role == $role);
}
</code></pre>

<p>The route group:</p>

<pre><code>Route::group(['prefix' =&gt; 'support', 'middleware' =&gt; ['role:admin', 'web']], function() {
        Route::get('threads', 'ThreadController@index');
});
</code></pre>

<p>In Http/Kernel.php:</p>

<pre><code>protected $middlewareGroups = [
    'web' =&gt; [
        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \App\Http\Middleware\VerifyCsrfToken::class,
    ],

    'role' =&gt; [
        RoleMiddleware::class,
    ],
];
</code></pre>

<p>Anyone have any ideas on what could be causing this ReflectionException?</p>