Ternary in Laravel Blade

后端 未结 5 1184
刺人心
刺人心 2020-12-23 11:02

Looking for a ternary operator for blade templates

@if(Auth::check()) ? yes : no @endif

Can\'t seem to get it to work this works

         


        
5条回答
  •  一整个雨季
    2020-12-23 11:45

    in addition, here is a nice shortcut ?:, if you you need to print some variable's value or if it's empty some default text

    {{ $value ?: 'Default Value' }}
    

提交回复
热议问题