@php $genral = App\Genral::first(); $banner = App\BannerSetting::first(); $allCats = App\Category::where('status', '1')->orderBy('position')->get(); $headerCats = $allCats->take(11); $cartCount = 0; $wishlistCount = 0; if (Auth::check()) { $cartCount = App\Cart::where('user_id', Auth::user()->id)->count(); // Count only wishlist rows that will actually render on the wishlist page: // the variant's product must still exist & be active, or it's a simple product. // Mirrors MainController::wishlist_show() so the badge never shows a phantom // count for a soft-deleted variant/product left behind in the table. $wishlistCount = App\Wishlist::where('user_id', Auth::user()->id) ->where(function ($q) { $q->whereHas('variant.products', function ($s) { $s->where('status', '1'); }) ->orWhereHas('simple_product'); })->count(); } else { $cartCount = Session::get('cart') ? count((array) Session::get('cart')) : 0; } $compareCount = count((array) session('comparison', [])); @endphp {{-- ===================== TOP UTILITY BAR ===================== --}}