<label class="select">
@if(is_null($alCities))
// whatever you need to do here
@else
@foreach($alCities as $city)
<?php $cts[] = $city->jobAdALCity; ?>
@endforeach
@endif
{!! Form::select('jobAdALCity[]',$cityArray,null,['id'=>'alCity','multiple']) !!}
</label>
Jul 6, 2015
5
Level 34
How to check If an array is not null in blade
I can check for a variable if it exists or not in blade like {{ $Variable or 'Default' }}
But how can i check if an array exists or it is null. What i am doing is passing an array of values to blade to populate a select box. But the array can be completely null due to back-end logic so what is the best way to check and iterate if array have values then iterate and pass as a third argument to Form::select otherwise pass null to select.
<label class="select">
{{ isset($alCities) ? $alCities : ' ' }}
@foreach($alCities as $city)
<?php $cts[] = $city->jobAdALCity; ?>
@endforeach
{!! Form::select('jobAdALCity[]',$cityArray,null,['id'=>'alCity','multiple']) !!}
</label>
Level 10
4 likes
Please or to participate in this conversation.