@php $isAssistant = (!empty($isPageAssistant) && $isPageAssistant) && !($page->present()->isAdmin() || $page->present()->isEditor()); $storeSwitchTarget = 'orderhistory'; if (! $isAssistant) { switch ((string) ($pageName ?? '')) { case 'sellingcats': $storeSwitchTarget = 'sellingcats'; break; case 'list': $storeSwitchTarget = 'marketplace'; break; case 'addproduct': $storeSwitchTarget = 'addproduct'; break; case 'taxsettings': $storeSwitchTarget = 'taxsettings'; break; case 'kyc': $storeSwitchTarget = 'taxdetails'; break; case 'orderhistory': default: $storeSwitchTarget = 'orderhistory'; break; } } $storeSwitchStores = collect(); if (\Auth::check()) { try { $pageAdminRepo = app('App\\Repositories\\PageAdminRepository'); $pageRepo = app('App\\Repositories\\PageRepository'); $adminPageIds = (array) $pageAdminRepo->getByUserId(\Auth::id()); $ownedPageIds = (array) $pageRepo->getByBusinesIds(); $ids = array_values(array_unique(array_filter(array_merge($adminPageIds, $ownedPageIds)))); $storeById = []; if (! empty($ids)) { $stores = \App\Models\Page::whereIn('id', $ids) ->where('is_deleted', '=', 0) ->where('community_id', '!=', 0) ->orderBy('id', 'desc') ->get(); foreach ($stores as $s) { $storeById[(int) $s->id] = $s; } } if (isset($assistantStores) && $assistantStores) { foreach ($assistantStores as $s) { if (! $s) { continue; } if ((int) ($s->is_deleted ?? 0) === 0 && (int) ($s->community_id ?? 0) !== 0) { $storeById[(int) $s->id] = $s; } } } if (! empty($page)) { $storeById[(int) $page->id] = $page; } $storeSwitchStores = collect($storeById)->sortBy(function ($p) { return strtolower((string) ($p->title ?? '')); }); } catch (\Throwable $e) { $storeSwitchStores = collect(); } } @endphp @if($storeSwitchStores && $storeSwitchStores->count() > 0)
@endif