0
0
Laravelframework~10 mins

Route naming 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 name the route 'home'.

Laravel
Route::get('/', function () {
    return view('welcome');
})->[1]('home');
Drag options to blanks, or click blank then click option'
Aname
Broute
Cas
Dalias
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'route' or 'as' instead of 'name' causes errors.
Forgetting to chain the method after the route definition.
2fill in blank
medium

Complete the code to name the route 'profile.show'.

Laravel
Route::get('/user/{id}', [UserController::class, 'show'])->[1]('profile.show');
Drag options to blanks, or click blank then click option'
Aname
Balias
Croute
Dlabel
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'alias' or 'label' which are not valid methods.
Placing the method before the route definition.
3fill in blank
hard

Fix the error in naming the route 'dashboard'.

Laravel
Route::get('/dashboard', function () {
    return view('dashboard');
})->[1]('dashboard');
Drag options to blanks, or click blank then click option'
Anamed
BrouteName
CsetName
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'named' instead of 'name' causes method not found errors.
Trying to set the name inside the route callback.
4fill in blank
hard

Fill both blanks to name a route group with prefix 'admin' and name prefix 'admin.'.

Laravel
Route::[1](['prefix' => 'admin', 'as' => 'admin.'], function () {
    Route::get('/users', [AdminUserController::class, 'index'])->[2]('users.index');
});
Drag options to blanks, or click blank then click option'
Agroup
Bname
Cprefix
Droute
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prefix' instead of 'group' for grouping routes.
Using 'route' instead of 'name' to name routes.
5fill in blank
hard

Fill all three blanks to define a named route with middleware and name 'profile.edit'.

Laravel
Route::get('/profile/edit', [ProfileController::class, 'edit'])
    ->middleware('[1]')
    ->[2]('[3]');
Drag options to blanks, or click blank then click option'
Aauth
Bname
Cprofile.edit
Dguest
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'guest' middleware instead of 'auth' for protected routes.
Forgetting to chain the 'name' method after middleware.