In this tutorial, I will show you how to write if else statement and multiple if else statements in the Laravel blade file. You know that blade is a template engine and we can not use normal PHP without using the @php @endphp blade directive. But we can do it in the blade file also. 

Let's see the example code:


@if($user->name == 'John Doe')
  {{ 'do something' }}


We can also if else ladder in blade file. See the code:

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


Read also: Laravel 9 Define Route With Parameter In Blade


Hope it can help you.