Laravel Blade Empty Directive Example

By Hardik Savani April 16, 2024 Category : Laravel


If you need to see example of laravel blade empty directive. we will help you to give example of laravel blade check if variable is empty. i explained simply step by step check empty in laravel blade. This article goes in detailed on laravel @empty directive example.

we will learn simple examples of how to check variable is empty or not in laravel 6, laravel 7, laravel 8, laravel 9, laravel 10 and laravel 11.

let's see bellow simple example:

Blade File Code:

<!DOCTYPE html>







<p> user variable is empty.</p>



<p> admin variable is not empty.</p>


<p> admin variable is empty.</p>




Controller File Code:


namespace App\Http\Controllers;

use Illuminate\Http\Request;

class AjaxController extends Controller



* Create a new controller instance.


* @return void


public function index()


$user = '';

$admin = 1;

return view('ajaxRequest', compact('user', 'admin'));




user variable is empty.

admin variable is not empty.

I hope it can help you...

Tags :