0
0
Laravelframework~10 mins

Why routing maps URLs to logic in Laravel - Test Your Understanding

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

Complete the code to define a route that returns a view named 'welcome'.

Laravel
Route::get('/', function() {
    return [1]('welcome');
});
Drag options to blanks, or click blank then click option'
Aresponse
Bredirect
Cview
Droute
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'redirect' instead of 'view' causes a redirect instead of rendering.
2fill in blank
medium

Complete the code to define a route that calls the 'index' method of 'HomeController'.

Laravel
Route::get('/home', [[1]::class, 'index']);
Drag options to blanks, or click blank then click option'
AHomeController
BWelcomeController
CPageController
DMainController
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong controller name causes a class not found error.
3fill in blank
hard

Fix the error in the route definition to correctly map '/profile' to 'UserController@show'.

Laravel
Route::get('/profile', '[1]@show');
Drag options to blanks, or click blank then click option'
AUser_Controller
BProfileController
Cusercontroller
DUserController
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or wrong controller name causes routing errors.
4fill in blank
hard

Fill both blanks to create a route that accepts a 'post' parameter and calls 'show' method.

Laravel
Route::get('/posts/[1]', [PostController::class, '[2]']);
Drag options to blanks, or click blank then click option'
A{post}
Bshow
Cindex
Dcreate
Attempts:
3 left
💡 Hint
Common Mistakes
Using method 'index' or 'create' instead of 'show' for single resource display.
5fill in blank
hard

Fill all three blanks to define a POST route to 'store' method with middleware 'auth'.

Laravel
Route::[1]('/posts', [PostController::class, '[2]'])->middleware('[3]');
Drag options to blanks, or click blank then click option'
Aget
Bstore
Cauth
Dpost
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' instead of 'post' for data submission routes.