Hello Devs, 

In this tutorial, we will learn Laravel Blade If Condition Example

You may construct if statements using the @if, @elseif, @else, and @endif directives.

Follow this step-by-step guide below. 

Example: if, endif Condition

Syntax

@if (condition)
    // Statements inside body of if
@endif

Example

@if (count($type) === 1)
    I have one record!
@endif


Example: if..else..endif condition:

Syntax

@if (condition)
    // Statements inside body of if
@else
    //Statements inside body of else
@endif


Example

@if (count($type) === 1)
    I have one record!
@else
    I don't have any records!
@endif


Example: if..elseif..else..endif Condition:

Syntax

@if (condition)
    // Statements inside body of if
@elseif (condition)
    // Statements inside body of else if
@else
    //Statements inside body of else
@endif

Example

@if (count($type) === 1)
    I have one record!
@elseif (count($type) > 1)
    I have multiple records!
@else
    I don't have any records!
@endif

May this example help you.