Hello Devs,
In this tutorial, we will learn Laravel Blade If Multiple Conditions Example
If You have to use @if, @else, and @elseif directives to construct if statement, else statement and elseif statement respectively. Similarly, the @endif directive will end the if statement for you.
Follow this step-by-step guide below,
Syntax:
@if (condition)
......
@elseif (condition)
.....
@else
.....
@endif
Example :
<!DOCTYPE html>
<html>
<head>
<title>Laravel Blade If Multiple Conditions Example</title>
</head>
<body>
<h1>Laravel Blade If Multiple Conditions Example - rathorji.in</h1>
@if (count($records) === 1)
<p>I have one record!</p>
@elseif (count($records) === 2)
<p>I have two records!</p>
@elseif (count($records) > 1)
<p>I have multiple records!</p>
@else
<p>I don't have any records!</p>
@endif
</body>
</html>
May this example help you.