Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save abdullahbutt/ec13905dc5312be125f0cc84b40ae650 to your computer and use it in GitHub Desktop.

Select an option

Save abdullahbutt/ec13905dc5312be125f0cc84b40ae650 to your computer and use it in GitHub Desktop.
ternary operator blade if else on single line
How to make if else statement on a single line in a blade? How to compress the below on to a single line.
@if ($var === "hello")
Hi
@else
goodbye
@endif
Solution:
{{ $var === "hello" ? "Hi" : "Goodbye" }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment