Dwight Watson's blog

Laravel 4 intended redirect with named route

This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.

We had a hiccup recently where we had changed the URI of the page a user would be redirected to after logging in. Because we had been using return Redirect::intended('/home') we didn't initially catch that if no intended path was in the session, logged in users would be redirected to the hard-coded path instead of a named route. I made a pull request to add a new method called intendedWithRoute() which would also allow you to pass a named route and parameters, but it was not merged.

Instead, Taylor suggested this option which was a silly oversight on my part. I wrote about this solution for others the might come across the same problem.

// Use the route() helper function to generate the route path for the intended() method.
return Redirect::intented(route('home'));

A blog about Laravel & Rails by Dwight Watson;

Picture of Dwight Watson

Follow me on Twitter, or GitHub.