We may require to redirect named route with another parameters or query string in laravel application, you can do it simply by using "redirect()" helper. redirect() helper provide method route for redirect named route. In this example i will show you how to redirect simple named route, redirect with named route and params, redirect with named route with message. You can simple use and understand.
So here, let's see how you can redirect route in your controller method:
Redirect to Named Route
public function show()
{
return redirect()->route('home');
}
Redirect to Named Route with parameters
public function show()
{
return redirect()->route('item.view',['id'=>2]);
}
Redirect to Named Route with query string
public function show()
{
return redirect()->route('home')
->with('message','I am back to home page.');
}
As above example you can simple return redirect using route name, you can also do it using url, but i will put article soon for that.
Do you like below Tutorials ?
- Multidimensional Array Search By Value in PHP
- Laravel Install Font Awesome Icons Example
- How to Use Moment JS in Laravel?
- Angular 9 Get Environment Variables Example
- Angular Delete a Component From Cli Example
- How to Upload File from Local to Server using SSH?
- Angular Use CKEditor Example Tutorial
- How to Use Multiple Select Dropdown in Laravel?