Laravel : Multi Guard in Auth Middleware
<p>I have a Laravel Application using Multi User tables for different roles.</p>

<p>I have added 2 custom guards like this:</p>

<pre><code>'guards' =&gt; [
    'consumer' =&gt; [
        'driver' =&gt; 'session',
        'provider' =&gt; 'consumer',
    ],
    'member' =&gt; [
        'driver' =&gt; 'session',
        'provider' =&gt; 'member',
    ]
]
</code></pre>

<p>And I want to share the the same route with both of consumer and member. But I dont know how Laravel pass guard name to the Auth middleware.</p>

<p>Look at file <code>Illuminate\Auth\Middleware\Authenticate</code> </p>

<pre><code>protected function authenticate(array $guards)
{
    if (empty($guards)) {
        return $this-&gt;auth-&gt;authenticate();
    }

    foreach ($guards as $guard) {
        if ($this-&gt;auth-&gt;guard($guard)-&gt;check()) {
            return $this-&gt;auth-&gt;shouldUse($guard);
        }
    }

    throw new AuthenticationException('Unauthenticated.', $guards);
}
</code></pre>

<p>If I can pass 2 custom guards to the $guards variable, It can share the route between custom and user. But I dont know how to pass the guard's name</p>