Blog User Guide Documentation API Login Register

Documentation > Theme Development

If Statements

Last updated February 16, 2024

You may construct if statements using the @if, @elseif, @else, and @endif directives. These directives function identically to their PHP counterparts:

@if (count($records) === 1)
    // I have one record!
@elseif (count($records) > 1)
    // I have multiple records!
@else
    // I don't have any records!
@endif

For convenience, Blade also provides an @unless directive:

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

In addition to the conditional directives already discussed, the @isset and @empty directives may be used as convenient shortcuts for their respective PHP functions:

@isset($records)
    // $records is defined and is not null...
@endisset

@empty($records)
    // $records is "empty"...
@endempty