我第一次使用网络防护来创建其他类型的用户,在我的情况下是候选人和雇主,它看起来工作正常,但我注意到一个细节,我有一个部分称为nav.blade.ph
p我有菜单标题和用户帐户链接列表,如果用户登录,它应显示管理链接,如果没有显示登录或注册按钮。我登录时菜单会部分更新,但我注意到只有当路线在警卫室内时它才起作用,我不明白为什么不在主页上工作部分导航(例如中间件)。
有些人可以告诉我缺少什么吗?
路线:
Route::get('/','PageController@getHome');
// CANDIDATE PRIVATE AREA
Route::group(['middleware' => ['auth:candidate']], function() {
Route::prefix('candidate')->group(function(){
Route::get('/panel','CandidateController@dashboard');
});
部分nav.blade.php
@if(Auth::check())
<li class="dropdown">
<a href="/" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ Auth::User()->name }} <span class="caret"></span></a>
<ul class="dropdown-menu">
@if(Auth::guard('employer')->check())
<li><a href=""><span class="glyphicon glyphicon-home" aria-hidden="true"></span> Dashboard</a></li>
<li><a href=""><span class="glyphicon glyphicon-user" aria-hidden="true"></span> Settings</a></li>
<li><a href=""><span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span> Online Store</a></li>
@endif
@if(Auth::guard('candidate')->check())
<li><a href="{{route('candidate-dashboard')}}">Panel</a></li>
@endif
<li role="separator" class="divider"></li>
<li> <a href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
<span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> Logout
</a></li>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
@else
<div class="navbar-form">
<a class="btn btn-success " href="">Login</a> | <a class="btn btn-success " href="">Register</a>
</div>
@endif
答案 0 :(得分:0)
试试这个:
Route::get('/','PageController@getHome');
// CANDIDATE PRIVATE AREA
Route::group(['middleware' => ['guest:candidate']], function() {
Route::prefix('candidate')->group(function(){
Route::get('/panel','CandidateController@dashboard');
});