{{-- Ad Banner Component --}} {{-- Usage: or --}} @props(['placement' => 'header', 'slug' => null]) @php $cacheKey = "ads_{$placement}" . ($slug ? "_{$slug}" : ''); $cacheTtl = 300; // 5 minutes $ads = \Illuminate\Support\Facades\Cache::remember($cacheKey, $cacheTtl, function () use ($placement, $slug) { $query = \App\Models\Ad::current() ->forPlacement($placement) ->orderBy('sort_order'); if ($slug) { $query->where('section_slug', $slug); } return $query->get(); }); if ($ads->isEmpty()) { return; } // Rotation: pick one randomly if multiple, otherwise use first $ad = $ads->count() > 1 ? $ads->random() : $ads->first(); @endphp @if($placement === 'header') {{-- Header Banner: full-width horizontal strip --}}
@if($ad->link_url) {!! $ad->body !!} @else
{!! $ad->body !!}
@endif
@elseif($placement === 'section') {{-- Section Banner: container-width, between page sections --}}
@if($ad->link_url) {!! $ad->body !!} @else
{!! $ad->body !!}
@endif
@endif