#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

Blade Directives (@if, @foreach, @include)

Blade directives are shorthand for common PHP control structures, written with an @ prefix instead of PHP's usual <?php ?> tags. They make views far easier to scan, since logic reads almost like plain English.

Conditional Directives

Blade offers direct equivalents for PHP's conditional statements, letting a view decide what to display without breaking out of the templating syntax. This keeps HTML and logic visually distinct while still being fully dynamic.

Looping Directives

Displaying a list of records, like blog posts or products, is one of the most common tasks in any view. Blade's looping directives handle this cleanly, and a special $loop variable is available inside them for tracking index, position, and iteration count.

DirectiveWhat It Does
@if / @elseif / @else / @endifRenders content conditionally
@foreach ... @endforeachLoops over a collection or array
@forelse ... @empty ... @endforelseLoops over data, with a fallback if it's empty
@include('partial')Inserts another Blade view inline
@auth / @guestChecks whether a user is logged in

Reusing Views with @include

Directives handle logic inside a single view, but most real applications also need a consistent page structure across many views — which is exactly what Blade layouts and sections solve.

Ready to master Laravel Training Course?

Join Uncodemy's hands-on Laravel program and build real, production-ready applications.

Explore Course