10-Apr-2023
.
Admin
Hello Friends,
In this article, I will learn how to use if multiple condition in laravel blade application. We will talk about if statement with multiple condition in laravel app. I am going to learn you laravel blade if multiple conditions. This article will give you laravel blade if multiple conditions.
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.
You may construct if statements using the @if, @elseif, @else, and @endif directives. These directives function identically to their PHP counterparts:
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 - NiceSnippets.com</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>
I hope it will help you....
#Laravel 8
#Laravel 7
#Laravel
#Laravel 6