@php if(session()->has('pincode_details')) { $pincode_details = session()->get('pincode_details'); $pincode = isset($pincode_details['pincode']) ? $pincode_details['pincode'] : ''; $city = isset($pincode_details['city']) ? $pincode_details['city'] : ''; } else { $pincode = ''; $city = ''; } $currentLocation = session()->get('currentLocation'); $currentPincode = isset($currentLocation['pincode']) ? $currentLocation['pincode'] : ''; $currentCity = isset($currentLocation['city']) ? $currentLocation['city'] : ''; $hasLocation = !empty($city) || !empty($pincode); // Optimized DB Queries: Run only if user is logged in $authUserId = Auth::check() ? Auth::user()->id : ""; $authUserName = Auth::check() ? Auth::user()->name : ""; $authUserImage = Auth::check() ? Auth::user()->avatar : ""; $chekPartner = null; $userNotification = collect(); $userNotificationCount = 0; if(Auth::check()) { $chekPartner = \App\Models\Affiliate::where('user_id', $authUserId)->first(); $userNotification = App\Models\FirebaseNotification::where('is_read', 0) ->where('receiver_id', $authUserId) ->where('send_by', 'admin') ->latest() ->limit(5) ->get(); // FIX: reuse the already-loaded collection instead of second DB query $userNotificationCount = $userNotification->count(); } @endphp @if(get_setting('topbar_banner') != null)
@endif