When I print i got collection of two null array as:
array:2 [▼
0 => Collection {#419 ▼
#items: []
}
1 => Collection {#412 ▼
#items: []
}
]
In a count of this null array I got "Count - 2". What i want to do with my code that loop two times (which is my count) and check that if in ARRAY-1 data is available then print "data available" else print "data not available".
Here is my code:
two foreach loop because of collection of array
foreach($TestArr as $TestArr1) {
foreach($TestArr1 as $item) {
if($item->gallery_id == $val && $item->is_thumb_image == 1) {
echo "YesImage";
} else {
echo "NoImage";
}
}
}
Here is a full code;
<div class="container">
@if(!empty($galleryArr)) // Gt a folder name
@foreach($galleryArr as $key => $val)
<div class="col-md-3">
<div class="service-block service1">
<?php
foreach($TestArr as $TestArr1) { //set for thumb image
if(count($TestArr1)){
foreach($TestArr1 as $item) {
if($item->gallery_id == $val && $item->is_thumb_image == 1) {
echo "YesImage";
}
}
}else{
echo "NoImage";
}
}
?>
<h4>{{ $key }}</h4>
<a href="javascript:void(0);" class="btn" id="dynamic_{{$val}}">View Gallary</a>
<script type="text/javascript">
// added
$('#dynamic_{!! $val !!}').on('click', function() {
$(this).lightGallery({
dynamic: true,
dynamicEl: [
<?php if(!empty($mediaData)){
foreach($mediaData as $k => $v){
if($v->gallery_id == $val){ ?>
{
"src": '{!! "/images/".$v->path !!}',
'thumb': '{!! "/images/".$v->path !!}',
'subHtml': '<h4>{{ $v->caption }}</h4>'
},
<?php } } }?>
]
})
});
</script>
</div>
</div>
@endforeach
@endif
</div>