Recall & Review
beginner
What is a Blade directive in Laravel?
A Blade directive is a special instruction in Laravel's Blade templating engine that starts with @ and helps you write PHP code in your HTML templates easily and cleanly.
Click to reveal answer
beginner
How do you write an if statement using Blade directives?
You use @if(condition) to start, @elseif(condition) for else if, @else for else, and close with @endif.
Click to reveal answer
beginner
What does the @foreach directive do in Blade?
@foreach loops over each item in a collection or array and lets you display or process each item inside the loop.
Click to reveal answer
intermediate
Explain the purpose of the @csrf directive.
@csrf adds a hidden input field with a security token to your forms. This helps protect your app from cross-site request forgery attacks.
Click to reveal answer
beginner
How do you include another Blade view inside a Blade template?
Use the @include('view.name') directive to insert the content of another Blade view into your current template.
Click to reveal answer
Which Blade directive is used to start a loop over an array?
✗ Incorrect
@foreach is used to loop over arrays or collections in Blade templates.
What does the @csrf directive do in a Blade form?
✗ Incorrect
@csrf adds a hidden input with a token to protect forms from cross-site request forgery.
How do you end an if statement in Blade?
✗ Incorrect
You close an if statement with @endif in Blade templates.
Which directive would you use to insert another Blade view inside your template?
✗ Incorrect
@include inserts the content of another Blade view into the current template.
What symbol do all Blade directives start with?
✗ Incorrect
Blade directives always start with the @ symbol.
Describe how you would use Blade directives to create a conditional message that shows 'Welcome!' only if a user is logged in.
Think about how to check a condition and show content only when true.
You got /4 concepts.
Explain the role of the @csrf directive in Blade templates and why it is important for forms.
Consider what security risks forms face and how Laravel helps prevent them.
You got /4 concepts.