© Sanjib Sinha 2019
S. SinhaBeginning Laravel https://doi.org/10.1007/978-1-4842-4991-8_6

6. Handling User Data and Redirects

Sanjib Sinha1 
(1)
Howrah, West Bengal, India
 

A redirect is a kind of response; it’s part of a request-response cycle in Laravel. Therefore, Laravel has designed it as a RedirectResponse instance or object that you can use through the global helper function redirect() . It comes from Illuminate\Http\RedirectResponse. You need it for many reasons. One of them is to validate a user’s data or input. If the user input is invalid, it is a responsibility of a well-designed application to send the user a message and return to the original state.

If you want to redirect to the previous location, another good method is the back() global ...

Get Beginning Laravel: Build Websites with Laravel 5.8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.