Blade Template Syntax Basics
📖 Scenario: You are building a simple Laravel web page that shows a list of fruits and highlights those that are fresh.
🎯 Goal: Create a Blade template that displays a list of fruits from a given array. Use Blade syntax to loop through the fruits and conditionally show 'Fresh!' next to fruits that are fresh.
📋 What You'll Learn
Create a Blade variable called
$fruits with exact entriesCreate a Blade variable called
$freshThreshold with the exact valueUse a
@foreach loop with variables $fruit and $status to iterate over $fruitsUse a Blade
@if directive to check if $status equals 'fresh' and display 'Fresh!' text💡 Why This Matters
🌍 Real World
Blade templates are used in Laravel to create dynamic HTML pages that respond to data and user input.
💼 Career
Understanding Blade syntax is essential for Laravel developers to build maintainable and efficient web applications.
Progress0 / 4 steps