Laravel 8 route groups allow you to group all the routes related to your modules. Routes Groups are helpful in the situation when you want to apply one attribute to all the routes.

Laravel 8 Route Groups

Route group takes an array that can take attributes and callback function. The route group allows you to share attributes such as middleware, prefixed, or namespaces without defining these attributes on each route.

These shared attributes can be passed in the array format as the first argument to the Route::group() function.

For example, if you want to apply a namespace to different routes, then you can do it by creating a route group and then apply the namespace on that group.

Syntax

Route::group( [ ] , callback);

Parameters

The group() function takes an array passed to the group method as a first parameter. The second parameter is the callback function.

#laravel #programming

Laravel 8 Route Groups Example
26.65 GEEK