title: Using Auth:User() in Laravel 5.2 view for nav
body: <p>I have an index route "/" that loads index.blade.php which extends the master. I'm unable to use Auth::User() in the nav bar which is a partial included from the master. It does work on pages that require authentication. I have Login and Register buttons that link the AuthController via /login and /register and would like those to be replaced by Logout when a authenticated user is viewing the "/" index page or any other page where authentication is not required.</p>
  
  <p>When a user logs in, the are redirected the the /dashboard route which works correctly and the nav bar shows correctly, but when they go an view the homepage, the login and register buttons are in the nav and clicking on them just redirects them back to the "/" index route, not showing a login or register form. (since they're already logged in i'm assuming.) The only way to get a form again is by manually entering /logout in the address bar.</p>
  
  <p>I've trying looking up answers all over the place but can't figure it out. </p>
  
  <p><code>dd(\Auth::user())</code> returns null in the controller.
  I've seen a lot of similar questions but having to do with older versions of Laravel but the solutions don't seem to work or I'm just not applying them correctly.</p>
  
  <p>Thanks for the help!</p>
  
  <p>route.php</p>
  
  <pre><code>Route::get('/','PagesController@index');
  Route::group(['middleware' =&gt; ['web']], function () {
          //    
          Route::controllers([
           'register' =&gt; 'Auth\AuthController',
           'password' =&gt; 'Auth\PasswordController',
          ]);
  });
  </code></pre>
  
  <p>PagesController.php</p>
  
  <pre><code>class PagesController extends Controller
  {
      //
  
      /**
       * Create a new controller instance.
       *
       * @return void
       */
      public function __construct()
      {
          //
  
      }
  
      public function index()
      {
  
          $nav_active = 'home';
  
          return view('pages.index',compact('nav_active'));
  </code></pre>
  
  <p>app.blade.php</p>
  
  <pre><code>&lt;ul class="nav navbar-nav navbar-right"&gt;
        @if (Auth::guest())
          &lt;li&gt;&lt;a href="{{ url('/login') }}"&gt;Login&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="{{ url('/register') }}"&gt;Register&lt;/a&gt;&lt;/li&gt;
        @else
          &lt;li class="dropdown"&gt;
              &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"&gt;
               {{ Auth::user()-&gt;name }} &lt;span class="caret"&gt;&lt;/span&gt;
              &lt;/a&gt;
              &lt;ul class="dropdown-menu" role="menu"&gt;
                  &lt;li&gt;&lt;a href="{{ url('/logout') }}"&gt;&lt;i class="fa fa-btn fa-sign-out"&gt;&lt;/i&gt;Logout&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/li&gt;
       @endif
  &lt;/ul&gt;
  </code></pre>
  
  <p>page/index.blade.app</p>
  
  <pre><code>@extends('layouts.app')
  
  @section('content')
  &lt;div class="container"&gt;
      ...
      &lt;/div&gt;
  &lt;/div&gt;
  @stop
  </code></pre>