Laravel blade @unless directive instead of @if statement Example

In this tutorial, you will learn Laravel blade @unless directive instead of @if Statement Example. Laravel provides @unless directive to use the same as @if statement.

The command @unless checks if our expression returns FALSE – then shows the following data. If the expression returns TRUE – it will ignore the inner part. Let’s see the below example for how to use laravel unless a directive is used in the blade view file.

Syntax:

@unless (condition)
    .....
@endunless

Example 1:

@unless (Auth::check())
    You are not signed in.
@endunless

Example 2:

@unless(count($posts) == 0)
{{ $post->title }}
@endunless

Hope this works for you.

Leave a Comment