title: How to use intended function in Laravel
body: <p>I need to register in a tournament with the URL:</p>
  
  <pre><code>http://laravel.dev/tournaments/1/register/
  </code></pre>
  
  <p>This URL is in the middleware 'auth', so if the user is not logged, he is redirected to login / page.</p>
  
  <p>What I need is to redirect to </p>
  
  <pre><code>http://laravel.dev/tournaments/1/register/
  </code></pre>
  
  <p>After login.</p>
  
  <p>In my routes.php, I have:</p>
  
  <pre><code>Route::get('tournaments/{tournamentId}/register', 'TournamentController@register');
  </code></pre>
  
  <p>I was told to use  </p>
  
  <pre><code>redirect()-&gt;intended
  </code></pre>
  
  <p>but I don't know how to do it.</p>
  
  <p>In the general case, User will be redirected to /admin, but in this case, I want him to keep doing his main action ( Register tournament)...</p>
  
  <p>I'm using the built in trait for login, so I checked what system do when login and it is already using this function:</p>
  
  <pre><code>protected function handleUserWasAuthenticated(Request $request, $throttles)
  {
      if ($throttles) {
          $this-&gt;clearLoginAttempts($request);
      }
  
      if (method_exists($this, 'authenticated')) {
          return $this-&gt;authenticated($request, Auth::guard($this-&gt;getGuard())-&gt;user());
      }
  
      return redirect()-&gt;intended($this-&gt;redirectPath());
  }
  </code></pre>
  
  <p>Thing is it will redirect me to a default path, not a dynamic one...</p>