0
0
Laravelframework~10 mins

Route groups in Laravel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start a route group with the prefix 'admin'.

Laravel
Route::[1](['prefix' => 'admin'], function () {
    // routes here
});
Drag options to blanks, or click blank then click option'
Amiddleware
Bprefix
Cgroup
Dresource
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prefix' instead of 'group' causes syntax errors.
Using 'middleware' or 'resource' does not create a route group.
2fill in blank
medium

Complete the code to add a middleware 'auth' to a route group.

Laravel
Route::group(['middleware' => [1]], function () {
    // protected routes
});
Drag options to blanks, or click blank then click option'
A'auth'
B'web'
C'api'
D'guest'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'guest' allows only guests, not authenticated users.
Using 'web' or 'api' are middleware groups, not specific auth.
3fill in blank
hard

Fix the error in the route group to correctly set both prefix and middleware.

Laravel
Route::group([1], function () {
    // routes
});
Drag options to blanks, or click blank then click option'
A['prefix' => 'dashboard', 'middleware' => 'auth']
B['prefix' => dashboard, 'middleware' => auth]
C['prefix' => 'dashboard', 'middleware' => ['auth']]
D['prefix' => 'dashboard', middleware => 'auth']
Attempts:
3 left
💡 Hint
Common Mistakes
Missing quotes around keys or values causes syntax errors.
Using array for middleware is valid but not required here.
4fill in blank
hard

Fill both blanks to create a route group with prefix 'api' and middleware 'auth:api'.

Laravel
Route::group(['[1]' => 'api', '[2]' => 'auth:api'], function () {
    // api routes
});
Drag options to blanks, or click blank then click option'
Aprefix
Bmiddleware
Cguard
Dnamespace
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'guard' or 'namespace' keys instead of 'prefix' or 'middleware'.
Swapping the keys causes unexpected behavior.
5fill in blank
hard

Fill all three blanks to create a route group with prefix 'admin', middleware 'auth', and namespace 'Admin'.

Laravel
Route::group(['[1]' => 'admin', '[2]' => 'auth', '[3]' => 'Admin'], function () {
    // admin routes
});
Drag options to blanks, or click blank then click option'
Aprefix
Bmiddleware
Cnamespace
Ddomain
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'domain' instead of 'namespace' for controller grouping.
Mixing up the order of keys.