Laravel - Responses - Redirects

Redirect responses are instances of the Illuminate\Http\RedirectResponse class, and contain the proper headers needed to redirect the user to another URL. There are several ways to generate a RedirectResponse instance. The simplest method is to use the global redirect helper:

    
    Route::get('/dashboard', function () {
        return redirect('home/dashboard');
    });
	

Sometimes you may wish to redirect the user to their previous location, such as when a submitted form is invalid. You may do so by using the global back helper function. Since this feature utilizes the session, make sure the route calling the back function is using the web middleware group:

    
    Route::post('/user/profile', function () {
        // Validate the request...
    
        return back()->withInput();
    });