I have a Blade template that loads a list of users and displays their various details.
If a user has no mobile number I want to display the message "No Mobile Number" (I've tried single and double quotes), this never gets displayed:
@if ($person->Mobile >= "")
{{ $person->Mobile }}
@else
'No Mobile Number'
@endif
I tried substituting the "No Mobile" message with {{ $person->EMail }} (which I'm displaying elsewhere, so I know everyone has an email address), but still go nothing, as far as I can tell the logic isn't going into the @else block.
Any ideas?
This should work
@if (!empty($person->Mobile))
{{{ $person->Mobile }}}
@else
'No Mobile Number'
@endif
I use this approach:
@if( isset($error_message) )
@section('content')
@parent
@stop
@section('error_message')
<strong>Holly molly! </strong><em>{{ $error_message }} :(</em>
@stop
@endif
I have a section content and inside content have another section error_message so if error_message
variable is set, show that content section and inside print my error_message
.
PD: I haven't my original code to hand... Im currently using Twig as primary template engine in Laravel4. Twig beats Blade in simplycity and is very usefull