2017-08-15 58 views
-1

我第一次使用網絡守衛來創建其他類型的用戶,在我的情況下是候選人和僱主,它看起來工作正常,但我注意到一個細節,我有一個名爲nav.blade.ph p的部分,我有菜單標題和用戶帳戶鏈接列表,如果用戶登錄它應顯示管理的鏈接,如果沒有它顯示用於登錄或註冊的按鈕。菜單部分更新,當我登錄時,但我注意到它只適用於當一個警衛內部的路線,我不明白爲什麼不工作的部分導航例如在主頁上(中間件外) 。未通過身份驗證時顯示數據(守衛)

有人能告訴我什麼是缺失?

路線:

Route::get('/','[email protected]'); 

// CANDIDATE PRIVATE AREA 
Route::group(['middleware' => ['auth:candidate']], function() { 

    Route::prefix('candidate')->group(function(){ 
     Route::get('/panel','[email protected]'); 

}); 

部分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

試試這個:

Route::get('/','[email protected]'); 

// CANDIDATE PRIVATE AREA 
Route::group(['middleware' => ['guest:candidate']], function() { 

    Route::prefix('candidate')->group(function(){ 
     Route::get('/panel','[email protected]'); 

}); 
相關問題