Using @if Control Structures in Blade

Problem

You need conditional logic in a Blade template.

Solution

Use the @if control structure.

@if ($age < 6)
    Get outta here kid.
@elseif ($age < 21)
    You can't buy booze in the United States.
    Ha ha.
@else
    Buy me a drink?
@endif

Discussion

Nothing to discuss.

comments powered by Disqus