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.
For Laravel 5 + php7, you should be using the null coalesce operator as explained in this Laravel News article, like so:
{{ $value ?? "Fallback" }}
Before the null coalescing operator, Blade handled the same problem with the “or” operator, which allows a default value when the first value isn’t set, separated by an “or”.