Laravel Responses: Redirects

Route::get('dashboard', function () {
    return redirect('home/dashboard');
Route::post('user/profile', function () {
    // Validate the request...

    return back()->withInput();

Redirect responses are instances of the Illuminate\Http\RedirectResponse class, and contain the proper headers needed to redirect the user to another URL.

Redirecting To Named Routes

Return redirect()->route('login');
// For a route with the following URI: profile/{id}

return redirect()->route('profile', ['id' => 1]);

To generate a RedirectResponse to a named route, you may use the route method.

If your route has parameters, you may pass them as the second argument to the route method.

Redirecting To Controller Actions

Return redirect()->action('HomeController@index');
Return redirect()->action(
    'UserController@profile', ['id' => 1]);

Redirecting To External Domains

Return redirect()->away('');

Redirecting With Flashed Session Data

Route::post('user/profile', function () {
    // Update the user's profile...

    return redirect('dashboard')->with('status', 'Profile updated!');
@if (session('status'))
    <div class="alert alert-success">
        {{ session('status') }}

Laravel Responses: Redirects — Structure map

Clickable & Draggable!

Laravel Responses: Redirects — Related pages: