{{-- App Download Banner - shown to vendors/managed users (vendor app) or non-vendor users (root app) --}} @auth @php $vendorApp = null; try { $currentUser = Auth::user(); $targetVendor = null; if (method_exists($currentUser, 'isVendor') && $currentUser->isVendor()) { // User is a vendor — use their own vendorProfile $targetVendor = $currentUser->vendorProfile; } elseif (method_exists($currentUser, 'isManaged') && $currentUser->isManaged()) { // User is managed by a vendor — use the parent vendor $targetVendor = $currentUser->vendor; } if ($targetVendor && $targetVendor->vendorApp) { $appWithVersions = $targetVendor->vendorApp; if ($appWithVersions->versions()->exists()) { $vendorApp = $appWithVersions; } } // Fallback: show root app for users without a vendor_id if (!$vendorApp && empty($currentUser->vendor_id)) { $rootApp = \App\Models\VendorApp::where('is_root', true)->first(); if ($rootApp && $rootApp->versions()->exists()) { $vendorApp = $rootApp; } } } catch (\Exception $e) { // Silently fail - don't break the layout } @endphp @if($vendorApp)
@endif @endauth