Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'route' or 'as' instead of 'name' causes errors.
Forgetting to chain the method after the route definition.
✗ Incorrect
In Laravel, the name method assigns a name to the route.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'alias' or 'label' which are not valid methods.
Placing the method before the route definition.
✗ Incorrect
The name method is used to assign a name to the route, which helps in generating URLs.
3fill in blank
hardFix 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'
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.
✗ Incorrect
The correct method to name a route is name. Using named or others causes errors.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prefix' instead of 'group' for grouping routes.
Using 'route' instead of 'name' to name routes.
✗ Incorrect
Use group to create a route group and name to name individual routes inside it.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'guest' middleware instead of 'auth' for protected routes.
Forgetting to chain the 'name' method after middleware.
✗ Incorrect
Use middleware('auth') to protect the route, then name('profile.edit') to name it.