Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The 'get' method defines a route that responds to HTTP GET requests, which is typical for displaying pages.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'make:model' instead of 'make:controller'.
Confusing migrations or seeders with controllers.
✗ Incorrect
The 'make:controller' command creates a new controller class in Laravel.
3fill in blank
hardFix 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'
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.
✗ Incorrect
The 'index' method is conventionally used to show the main page or list in a controller.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'redirect' instead of 'view' to return a page.
Using wrong view names like 'home' instead of 'dashboard'.
✗ Incorrect
The 'view' helper returns a view, and 'dashboard' is the name of the view to show.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'post' instead of 'get' for a page route.
Wrong method name or route name strings.
✗ Incorrect
The route uses 'get' method, calls 'index' method of controller, and names the route 'home.index'.