Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the Blade template code to display a variable called $title.
Laravel
<h1>[1]</h1> Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using @title instead of $title
Omitting the $ sign before the variable name
Using double curly braces inside the code incorrectly
✗ Incorrect
In Laravel Blade templates, variables are displayed using double curly braces with the variable name, like {{$title}}.
2fill in blank
mediumComplete the Blade directive to include a child template named 'header'.
Laravel
@include('[1]')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including the wrong template name
Forgetting to put the template name in quotes
Using @include without parentheses
✗ Incorrect
The @include directive in Blade inserts the content of the specified template, here 'header'.
3fill in blank
hardFix the error in the Blade if statement to check if $user is set.
Laravel
@if(isset([1])) <p>Welcome, {{ $user->name }}!</p> @endif
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the $ sign before the variable
Using a wrong variable name
Using a capitalized variable name
✗ Incorrect
The isset function requires the variable with the $ sign, so use isset($user).
4fill in blank
hardFill both blanks to create a Blade loop that iterates over $items and displays each $item.
Laravel
@foreach([1] as [2]) <li>{{ $item }}</li> @endforeach
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting $ signs for variables
Using plural for the loop variable
Using wrong variable names
✗ Incorrect
The @foreach directive loops over $items as $item, using $ signs for variables.
5fill in blank
hardFill all three blanks to create a Blade conditional that checks if $count is greater than 0 and displays a message.
Laravel
@if([1] [2] [3]) <p>There are items.</p> @endif
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using == instead of >
Omitting $ sign for the variable
Using wrong numbers in the condition
✗ Incorrect
The condition checks if $count > 0 to confirm there are items.