Last updated
Last updated
We sometimes need to group our routes to save extra coding more prefixes and one-by-one tagging out middleware auth. Route groupings is here to save you.
$param : is an array that contains the prefix and the middleware of the group.
$action : is a function where we declare the routes inside.
For example, let's take a look with route grouping in our profile route.
grouping is just like saying: (/profile, /profile/changepass, /profile/delete)
.
First we need to define a prefix to our group by saying ['prefix' => 'your-desired-prefix']
and we define the middleware saying ['middleware' => ['auth']]
. Basically when saying ['middleware' => ['auth']]
all the routes the we define inside the group will be protected by auth. If you are not authenticated you cannot access this defined routes.