Home / Snippets / How to Check For Two isset in Laravel Blade Views
How to Check For Two isset in Laravel Blade Views cover

How to Check For Two isset in Laravel Blade Views

748

2 years ago

0 comments

Checking if a variable is defined and not empty can be achieved with "isset" and in Laravel blade you can make use of the provided directive.

Check single isset
Checking single isset with blade directive
@isset($user->username)
    <p>{{ $user->username }}</p>
@endisset

Checking Multiple isset
To check multiple isset with blade directive you can define it like below. Do note that this isset is check with AND and not an OR.
@isset($user->username, $user->gender)
    {{ $user->username }} {{ $user->gender }}
@endisset

To check if the value is set to only one of the values, you still have to use the if directive.
@if(isset($user->username) || isset($user->gender))
    {{ $user->username }} {{ $user->gender }}
@endif
notion avatar

Ahabz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this