Laravel 7刀片视图@guest和Auth::用户问题



我的导航中有一个按钮,如果你是@guest,则是连接模式的链接,而@else在Auth用户角色的功能中有两种显示,但我只看到@sle显示!

在本地的代客泊车一切都很好,这个问题只是当我在网上部署项目时。

@guest
<li class="nav-item ml-2">
<a class="nav-link text-success" id="conModal" href="" data-toggle="modal"
data-target="#connexionTarget">{{ __('Connexion') }}</a>
</li>
@else
@if(Auth::user()->role_id === 0)
<li class="nav-item ml-2 dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle text-success" href="#" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
{{ Auth::user()->firstName }} <span class="caret"></span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item linkCollapse infoUserBtn" href="" data-toggle="modal" data-target="#infoUser">
{{ __('Mon Profil') }}
</a>
<a class="dropdown-item linkCollapse userOrdersBtn" href="" data-toggle="modal" data-target="#userOrders">
{{ __('Mes Commandes') }}
</a>
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{ __('Déconnection') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST"
style="display: none;">
@csrf
</form>
</div>
</li>
@else
<li class="nav-item ml-2 dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle text-success" href="#" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
{{ Auth::user()->firstName }} <span class="caret"></span>
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{ __('Déconnection') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST"
style="display: none;">
@csrf
</form>
</div>
</li>
@endif
@endguest

您可以从这里查看Laravel文档控制结构>gt;身份验证指令

@auth和@guest指令可用于快速确定当前用户是否已通过身份验证或是guest:

@auth
// The user is authenticated...
@endauth
@guest
// The user is not authenticated...
@endguest

最新更新