title: Laravel redirect after login
body: <p>Here is the documentation</p>
  
  <blockquote>
    <p>When a user is successfully authenticated, they will be redirected to
    the <code>/home</code> URI. You can customize the post-authentication redirect
    location by defining a <code>redirectTo</code> property on the <code>LoginController</code>,
    <code>RegisterController</code>, and <code>ResetPasswordController</code>:</p>
    
    <p><code>protected $redirectTo = '/';</code></p>
    
    <p>If the redirect path needs custom
    generation logic you may define a <code>redirectTo</code> method instead of a
    <code>redirectTo</code> property:</p>
    
    <p><code>protected function redirectTo() {
        //
    }</code></p>
  </blockquote>
  
  <p>So I defined it</p>
  
  <pre><code>protected function redirectTo()
  {
      if (\Auth::user()-&gt;isAdmin()) {
          return '/dashboard';
      } else {
          return '/home';
      }
  }
  </code></pre>
  
  <p>But as you may guess, it does not work. It always redirects to <code>/home</code>.</p>
  
  <p>Going through sources, I found this</p>
  
  <pre><code>namespace Illuminate\Foundation\Auth;
  
  trait AuthenticatesUsers
  {
      ...
  
      /**
       * Send the response after the user was authenticated.
       *
       * @param  \Illuminate\Http\Request  $request
       * @return \Illuminate\Http\Response
       */
      protected function sendLoginResponse(Request $request)
      {
          $request-&gt;session()-&gt;regenerate();
  
          $this-&gt;clearLoginAttempts($request);
  
          return $this-&gt;authenticated($request, $this-&gt;guard()-&gt;user())
                  ?: redirect()-&gt;intended($this-&gt;redirectPath());
      }
      ...
  }
  </code></pre>
  
  <p>And this is implementation of <code>$this-&gt;redirectPath()</code></p>
  
  <pre><code>namespace Illuminate\Foundation\Auth;
  
  trait RedirectsUsers
  {
      /**
       * Get the post register / login redirect path.
       *
       * @return string
       */
      public function redirectPath()
      {
          return property_exists($this, 'redirectTo') ? $this-&gt;redirectTo : '/home';
      }
  }
  </code></pre>
  
  <p>I can't find where it checks for <code>redirectTo</code> method.</p>
  
  <p>I am using Laravel 5.3.28, BTW.</p>
  
  <p>Any suggestions?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This was fixed in 5.3.29, whereas I was on 5.3.29. Still I can't help it but think there is something wrong with documents, or this <code>laravel</code> helper they created to create Laravel projects. I did use it to generate project, and it fetched not the latest version.</p>