@php use App\Models\PopupModal; $now = \Carbon\Carbon::now(); // Get active modals with their associated pages $activeModals = PopupModal::with('pages') ->where(function($query) use ($now) { $query->where('start_date', '<', $now->format('Y-m-d')) ->orWhere(function($q) use ($now) { $q->where('start_date', '=', $now->format('Y-m-d')) ->where('start_time', '<=', $now->format('H:i:s')); }); }) ->where(function($query) use ($now) { $query->where('end_date', '>', $now->format('Y-m-d')) ->orWhere(function($q) use ($now) { $q->where('end_date', '=', $now->format('Y-m-d')) ->where('end_time', '>=', $now->format('H:i:s')); }); }) ->where('status', '=', '1') ->get(); // dd($activeModals); @endphp @foreach ($activeModals as $modal) @php $shouldShow = false; foreach ($modal->pages as $page) { // Home page check (exact match) if ($page->page_url === '/' && request()->is('/')) { $shouldShow = true; break; } // Category/page check (matches URL pattern) elseif (request()->is($page->page_url)) { $shouldShow = true; break; } } @endphp @php // dd($currentPath); // dd($shouldShow); @endphp @if ($shouldShow) @endif @endforeach