@php $isVendorAuthed = auth()->check() && (int) auth()->user()->user_type === 2; $routeName = request()->route() ? request()->route()->getName() : ''; $cartCount = 0; $vendorUnreadNotificationsCount = 0; $vendorRecentNotifications = collect(); if (auth()->check() && (int) auth()->user()->user_type !== 2) { $cartCount = (int) auth()->user()->cart()->sum('quantity'); } if ($isVendorAuthed) { $vendorUnreadNotificationsCount = (int) \App\Models\Notification::query() ->where('user_id', auth()->id()) ->where(function ($query) { $query->whereIn('type', ['order', 'payment', 'status_change', 'product_approval', 'product_rejection']) ->orWhereNull('type'); }) ->unread() ->count(); $vendorRecentNotifications = \App\Models\Notification::query() ->where('user_id', auth()->id()) ->where(function ($query) { $query->whereIn('type', ['order', 'payment', 'status_change', 'product_approval', 'product_rejection']) ->orWhereNull('type'); }) ->latest() ->take(5) ->get(); } @endphp