Laravel Blade Isset Else Example

About Us:

We are from free coder. We are a group of web developers who are passionate about web development. You can learn from us php, laravel, node js, vue js, react js and many other topic on web developement.
we are very happy to help you.
free coder

Today what you are going to learn:

Hello Brother, i will let you know lesson of laravel blade isset lesson. Here you will learn laravel blade isset directive. We will look at lesson of laravel blade @isset. step by step explain how to check variable is set or not in laravel. you will do the following things for how to check variable defined or not in laravel.

if you need to check variable set or not with if condition in laravel blade then i will give bellow lesson. you can also use in laravel 6, laravel 7 and laravel 8.

let's see bellow simple lesson:

Blade File Code:

<!DOCTYPE html>

<html>

<head>

<title></title>

</head>

<body>

@isset($user)

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

@endisset

@isset($status)

<p> status variable define.</p>

@endisset

@if(isset($admin))

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

@else

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

@endif

</body>

</html>

Controller File Code:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class AjaxController extends Controller

{

/**

* Create a new controller instance.

*

* @return void

*/

public function index()

{

$status = 1;

$admin = 1;

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

}

}

Result:-

status variable define.

admin variable is define.

thank you very much for following up with me.

Tags

Recent Posts

Related Posts