Using the @unless Control Structure in Blade


You need conditional logic in a Blade template.

You want to output html within the template when a condition is false. Yes, you know you can do @if ( ! condition), but are curious if there's a more elegant way.


Use the @unless control structure.

@unless ($age >= 18)
    You can't vote.


Pretty simple.

What Blade does internally is change your @unless(condition) into a if ( ! condition).

comments powered by Disqus