Reputation: 43
Is there a way to make something like this work?
{{ $user->name .' '. $user->last_name or '---' }}
Setting it up with @if-then isn't "elegant" as most of the laravel stuff is :)
Upvotes: 4
Views: 9127
Reputation: 1313
Check if $user->name
and $user->last_name
are not empty first, then determine what value you want to show with a shorthand if/else statement:
{{ ($user->name && $user->last_name) ? $user->name .' '. $user->last_name : '---' }}
Upvotes: 6