如何在Laravel中不进行认证

Eem*_*Jee 1 authentication laravel laravel-blade

我目前@auth('brand')在显示导航栏时正在使用,如果不进行身份验证,请隐藏导航栏并显示登录按钮。这是我到目前为止的内容:

@auth('brand')
 //show navigations
@endauth
if not auth
  Button Login
end not auth
Run Code Online (Sandbox Code Playgroud)

试过

if(!@auth('brand'))
 //show navigations
@endif
//but this is not working, it's showing the nav bar and the log in button
Run Code Online (Sandbox Code Playgroud)

有人对此有想法吗?

Jer*_*dev 7

大多数刀片指令可以使用该@else指令。

@auth('brand')
    //show navigations
@else
    // Show login
@endauth
Run Code Online (Sandbox Code Playgroud)

这是因为在生成的php代码中,@auth()伪指令被编译为用于检查身份验证状态的if结构。