In this article, I will share with you how to manage If elseif and else condition in laravel blade file. as you all know laravel is a provide manu easy to use functionality to use more make application code more less. in this example we see how to manage laravel blade file HTML content base on if, elseif or else condition base.
@if (condition)
/* Statements inside body of if */
@endif
@if($isAdmin == 1)
Admin User
@endif
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class AjaxController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function index()
{
$isAdmin = 1;
return view('ajaxRequest', compact('isAdmin'));
}
}
@if (condition)
/* Statements inside body of if */
@else
/* Else body of if */
@endif
@if($status == 1)
Active
@else
InActive
@endif
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class AjaxController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function index()
{
$status = 1;
return view('ajaxRequest', compact('status'));
}
}
@if (condition)
/* Statements inside body of if */
@elseif(condition)
/* if else inside body */
@else
/* Else body of if */
@endif
@if($status == 1)
Active
@elseif($status == 2)
Waiting
@else
InActive
@endif
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class AjaxController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function index()
{
$status = 3;
return view('ajaxRequest', compact('status'));
}
}
i hope you like this article.
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
Pie Chart Example using Google Chart in Laravel 7
Hello Artisan In this tutorial i will...How to calculate the number of words in a string using jQuery
Use the JavaScript split() met...How to Export CSV file in Laravel Example
In Laravel projects export csv and excel...Laravel 8 Generate Fake Data Using Faker Example
Sometimes you are testing project in loc...JWT Token Based Authentication API in NodeJs
Welcome, programming, buddies! Today, In...