title: Laravel 5 redirects back to home after login
body: <p>I have a page where users needs to login to click on a button, if they are not logged in they are taken to the login page to login. The problem is after the login they get redirected to home page. I would like them to be redirected back to the page they were before the login but can't get it to work.</p>
  
  <p>The method of the login is still 100% standard. I have tried editing this function but with no luck.</p>
  
  <pre><code>public function postLogin(Request $request)
  {
      $this-&gt;validate($request, [
          'email' =&gt; 'required|email', 'password' =&gt; 'required',
      ]);
  
      $credentials = $request-&gt;only('email', 'password');
  
      if ($this-&gt;auth-&gt;attempt($credentials, $request-&gt;has('remember')))
      {
          return redirect()-&gt;intended($this-&gt;redirectPath());
      }
  
      return redirect($this-&gt;loginPath())
                  -&gt;withInput($request-&gt;only('email', 'remember'))
                  -&gt;withErrors([
                      'email' =&gt; $this-&gt;getFailedLoginMessage(),
                  ]);
  }
  </code></pre>