Saturday, June 10, 2023

[php][laravel] what is the difference between Redirect::to() and Redirect::intended() ?

Redirect::to() or $redirect->to() will simply redirect the user to the page as the argument in the method.

.

Redirect::intended() or $redirect->intended() will redirect the user to where they were intended to go. For example, I tried to view a private page, but I was redirected to login. After I logged in, i'd be redirected to my intended location (the page I was trying to access). You can also add to the intended method, such as another page incase the page the user was intending to go to is no longer available.

 
.

No comments:

Post a Comment