2016-03-10 85 views
1

我使用laravel 5.2,我想改變菜單登錄退出時,用戶登錄,但 但如下圖所示enter image description here改變菜單的登錄與註銷laravel 5.2

的結果,這是我的代碼

<div id="headerweb"> 
    <div class="wrapper"> 
     <a href="/" class="mainlogo" target="_self"><img src="<?=asset('public/images/mainlogo.png')?>" alt=""/></a> 
     <div class="mainmenu"> 

      <ul> 
       <li><a href="carakerja" target="_self">CARA KERJA</a> </li> 
       <li><a href="order/pemeriksaan" target="_self">ORDER TES LAB</a> </li> 
       <li><a href="hasil" target="_self">HASIL LAB ONLINE</a> </li> 
       <li><a href="lokasilab" target="_self">LOKASI LAB</a> </li> 
       <li><a href="#">BLOG</a> </li> 
       @if (Auth::guest()) 
       <li><a href="login" target="_self">LOGIN</a> </li> 
       @else 
       <li class="dropdown"> 
        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> 
         {{ Auth::user()->name }} <span class="caret"></span> 
        </a> 

        <ul class="dropdown-menu" role="menu"> 
         <li><a href="{{ url('/logout') }}"><i class="fa fa-btn fa-sign-out"></i>Logout</a></li> 
        </ul> 
        @endif 
      </ul> 

     </div> 
    </div> 
</div><!-- endheaderweb --> 

任何一個幫助我?

+0

更改文件名文件名.blade.php,這是不接受你的刀片語法 – codeGig

+0

@AlexeyMezenin我不得不補充,但只是相同 –

+0

我已經改變了,但只是相同@Jitendra –

回答

0

請確保您已關閉@if聲明和#headerweb股利。

<div id="headerweb"> 
    <div class="wrapper"> 
     <a href="/" class="mainlogo" target="_self"><img src="<?=asset('public/images/mainlogo.png')?>" alt=""/></a> 
     <div class="mainmenu"> 

      <ul> 
       <li><a href="carakerja" target="_self">CARA KERJA</a></li> 
       <li><a href="order/pemeriksaan" target="_self">ORDER TES LAB</a></li> 
       <li><a href="hasil" target="_self">HASIL LAB ONLINE</a></li> 
       <li><a href="lokasilab" target="_self">LOKASI LAB</a></li> 
       <li><a href="#">BLOG</a></li> 
       @if (Auth::guest()) 
        <li><a href="login" target="_self">LOGIN</a></li> 
       @else 
        <li class="dropdown"> 
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> 
          {{ Auth::user()->name }} <span class="caret"></span> 
         </a> 

         <ul class="dropdown-menu" role="menu"> 
          <li><a href="{{ url('/logout') }}"><i class="fa fa-btn fa-sign-out"></i>Logout</a></li> 
         </ul> 
       @endif 
      </ul> 

     </div> 
    </div> 
</div> 

另外,請移動從routes.php文件的歡迎路線到Web中間件內,應該更改登錄註銷和登錄時顯示的用戶名。

Route::group(['middleware' => ['web']], function() { 
    Route::get('/', function() { 
     return view('welcome'); 
    }); 
});