I have a Laravel Application using Multi User tables for different roles.
I have added 2 custom guards like this:
'guards' => [
'consumer' => [
'driver' => 'session',
'provider' => 'consumer',
],
'member' => [
'driver' => 'session',
'provider' => 'member',
]
]
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.
Look at file Illuminate\Auth\Middleware\Authenticate
protected function authenticate(array $guards)
{
if (empty($guards)) {
return $this->auth->authenticate();
}
foreach ($guards as $guard) {
if ($this->auth->guard($guard)->check()) {
return $this->auth->shouldUse($guard);
}
}
throw new AuthenticationException('Unauthenticated.', $guards);
}
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