Laravel 中定义多个 guard 登录时,我们有时需要判断用户是通过哪个 guard 登录的,判断方法如下,以模板示例:

@if(Auth::guard('admin')->check())
    Hello {{Auth::guard('admin')->user()->name}}
@elseif(Auth::guard('user')->check())
    Hello {{Auth::guard('user')->user()->name}}
@endif