0
0
Laravelframework~10 mins

First Laravel application - Interactive Code Practice

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

Complete the code to create a new Laravel route that returns a welcome view.

Laravel
Route::[1]('/', function () {
    return view('welcome');
});
Drag options to blanks, or click blank then click option'
Aput
Bpost
Cget
Ddelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'post' instead of 'get' for a route that shows a page.
Confusing HTTP methods for simple page routes.
2fill in blank
medium

Complete the code to create a controller named HomeController using Artisan command.

Laravel
php artisan make:[1] HomeController
Drag options to blanks, or click blank then click option'
Acontroller
Bmigration
Cmodel
Dseeder
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'make:model' instead of 'make:controller'.
Confusing migrations or seeders with controllers.
3fill in blank
hard

Fix the error in the route definition to call the index method of HomeController.

Laravel
Route::get('/home', [HomeController::class, '[1]']);
Drag options to blanks, or click blank then click option'
Aindex
Bshow
Ccreate
Dstore
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'show' which usually displays a single item.
Using 'create' or 'store' which are for forms and saving data.
4fill in blank
hard

Fill both blanks to return a view named 'dashboard' from the controller method.

Laravel
public function index() {
    return [1]('[2]');
}
Drag options to blanks, or click blank then click option'
Aview
Bredirect
Cdashboard
Dhome
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'redirect' instead of 'view' to return a page.
Using wrong view names like 'home' instead of 'dashboard'.
5fill in blank
hard

Fill all three blanks to define a route that uses HomeController's index method and names the route 'home.index'.

Laravel
Route::[1]('/home', [HomeController::class, '[2]'])->name('[3]');
Drag options to blanks, or click blank then click option'
Aget
Bindex
Chome.index
Dpost
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'post' instead of 'get' for a page route.
Wrong method name or route name strings.