Advertisement

#3 Laravel 6 Basics | Routing (III) | Named Routes | Generating Named Routes URLs | Redirects

#3 Laravel 6 Basics | Routing (III) | Named Routes | Generating Named Routes URLs | Redirects In Part-3 of Laravel 6 Basics, we will continue learn about Routing in detail.

We will keep experimenting with lot of route functionalities in new Laravel 6 website and in E-com series.

In this video, we will learn about Named Routes.

Named Routes

We can give name to our routes so that we can use them easily anywhere we want.

We just need to specify a name for a route by adding the name method onto the route definition as shown in video.

We can specify route names for controller actions.

Generating URLs To Named Routes

Once we have assigned a name to a given route, we can use the route's name when generating URLs or redirects as shown in video.

Create one more route with controller action so that we can call named route in its function and will also redirect to named route.

Route::get('check-user','UsersController@checkUser');

If the named route defines parameters, we can pass the parameters as the second argument to the route function. The given parameters will automatically be inserted into the URL in their correct positions as shown in video.

If we pass additional parameters in the array, those key / value pairs will automatically be added to the generated URL's query string.

laravel 6 basics,laravel routing,laravel 6 named routes,laravel 6 give name to routes,laravel route names,naming to laravel routes,generating named routes urls,generating named routes redirects,named routes laravel basics,named routing laravel,routing names laravel,laravel route name integrate,give name to laravel routes,

Post a Comment

0 Comments