I have this code snippet but I am not sure what the difference between prefix
and name
is in the group parameters?
group([
#Get().route('/', 'WelcomeController@show').name('welcome'),
get('/', 'PostController@show').name('form'),
post('/store', 'PostController@store').name('create')
], prefix='blog.', name="blog."])
The prefix is actually the prefix to the route itself and
name
just prepends the name to the names of all routes inside the group.Take this for example:
what this snippet does is creates two routes to match the URL's of
/blog
and/blog/create
but also prepends the names to the routes such asblog.form
andblog.create
The names of the routes can be used for redirection:
or generating urls like this:
which generates the same URL as above.