@php
$routeName = request()->route() ? request()->route()->getName() : null;
$sidebarCurrentCompany = null;
$sidebarCurrentWebsite = null;
// Check if currentCompany was passed from controller (used by WebsiteController and others)
if (isset($currentCompany) && $currentCompany) {
$sidebarCurrentCompany = $currentCompany;
}
// Only set company context if not on companies.index
elseif (isset($company) && Str::startsWith($routeName, 'companies.') && $routeName !== 'companies.index') {
$sidebarCurrentCompany = $company;
}
// For websites.index and websites.create with company parameter, get company from request
elseif (($routeName === 'websites.index' || $routeName === 'websites.create') && request()->has('company')) {
$sidebarCurrentCompany = \App\Models\Company::find(request()->get('company'));
}
// Set website context for specific website routes (but NOT websites.index)
if (isset($website) && (
Str::startsWith($routeName, 'website.') ||
(Str::startsWith($routeName, 'websites.') && $routeName !== 'websites.index') ||
Str::startsWith($routeName, 'orders.') ||
Str::startsWith($routeName, 'pages.') ||
Str::startsWith($routeName, 'posts.') ||
Str::startsWith($routeName, 'post-categories.') ||
Str::startsWith($routeName, 'post-tags.') ||
Str::startsWith($routeName, 'products.') ||
Str::startsWith($routeName, 'product-categories.') ||
Str::startsWith($routeName, 'product-variations.') ||
Str::startsWith($routeName, 'menus.') ||
Str::startsWith($routeName, 'reports.') ||
Str::startsWith($routeName, 'marketplace.') ||
Str::startsWith($routeName, 'marketplace-integration.') ||
Str::startsWith($routeName, 'booking.') ||
Str::startsWith($routeName, 'payment-forms.') ||
Str::startsWith($routeName, 'marketing.') ||
Str::startsWith($routeName, 'customers.') ||
Str::startsWith($routeName, 'credit-packages.') ||
Str::startsWith($routeName, 'globals.')
)) {
$sidebarCurrentWebsite = $website;
$sidebarCurrentCompany = $website->company ?? null;
}
@endphp
@include('layouts.sidebar', [
'currentCompany' => $sidebarCurrentCompany,
'currentWebsite' => $sidebarCurrentWebsite
])
@include('layouts.navigation')
@yield('content')
@include('layouts.footer')