to_route() helper function

Laravel 9 provides shorter version of response()->route(), take a look on the following code:

1// Old way
2Route::get('redirectRoute', function() {
3 return redirect()->route('home');
4});
5 
6// Post Laravel 9
7Route::get('redirectRoute', function() {
8 return to_route('home');
9});

This helper work in the same way as redirect()->route('home'), but it is more concise than a old way.

Tip given by @CatS0up

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 22 courses (477 lessons, total 38 h 20 min)
  • 2 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord