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.


@unless (condition)

Example 1:

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

Example 2:

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

Hope this works for you.

Leave a Comment