@php // Filtrar solo los spots que tienen imagen $spotsArray = isset($spots) ? $spots->toArray() : []; $spotsArray = array_filter($spotsArray, function($spot) { return $spot && !empty($spot['image_url']); }); @endphp @if(count($spotsArray) > 0)
@foreach(array_slice($spotsArray, 0, 2) as $index => $spot)
@if(!empty($spot['spot_url'])) Anuncio {{ $index + 1 }} @else Anuncio {{ $index + 1 }} @endif
@endforeach
@if(count($spotsArray) > 2)
@foreach(array_slice($spotsArray, 2, 2) as $index => $spot)
@if(!empty($spot['spot_url'])) Anuncio {{ $index + 3 }} @else Anuncio {{ $index + 3 }} @endif
@endforeach
@endif
@endif