Looking for a ternary operator for blade templates
@if(Auth::check()) ? yes : no @endif
Can't seem to get it to work this works
@if(Auth::check()) yes @else no @endif
suppose there is not much in it for this example, just curious.
Looking for a ternary operator for blade templates
@if(Auth::check()) ? yes : no @endif
Can't seem to get it to work this works
@if(Auth::check()) yes @else no @endif
suppose there is not much in it for this example, just curious.
in addition, here is a nice shortcut
?:
, if you you need to print some variable's value or if it's empty some default textFor Laravel 5 + php7, you should be using the null coalesce operator as explained in this Laravel News article, like so:
You are free to use it with
{{ }}
.I know this question was asked a while ago, but this may help somebody.
You can now do this in Laravel 5.
Laravel 5 Blade Templates
Laravel 5.2 Blade Template
This works: