@php $module = request()->query('module') ?? (request()->is('fast-jdsports/footwear-request*') ? 'footwear' : (request()->is('fast-jdsports/price-check*') ? 'price' : (request()->is('fast-jdsports/stock-check*') ? 'stock' : 'footwear'))); $moduleNames = [ 'footwear' => 'Footwear Request', 'price' => 'Price Check', 'stock' => 'Stock Check' ]; $moduleRoutes = [ 'footwear' => route('footwear.request.index'), 'price' => route('price.check'), 'stock' => route('stock.check') ]; $isProductDetails = preg_match('/fast-jdsports\/(footwear-request|price-check|stock-check)\/[A-Za-z0-9=]+/', request()->path()); $isOtherBranch = request()->is('fast-jdsports/other-branch/*'); $isAlternateProducts = request()->is('fast-jdsports/alternate-products/*'); // Determine back link dynamically if ($isOtherBranch || $isAlternateProducts) { $backLink = url()->previous(); // Product Details page (previous link will work here) } elseif ($isProductDetails) { $backLink = $moduleRoutes[$module]; // Go back to module page } else { $backLink = route('home'); // Go back to Home for base module pages } @endphp {{-- Header with back button + breadcrumbs --}}