get('template'); // Map component names to their blade views $componentMap = [ 'home-popular-products' => 'components.home.home-popular-products', 'product-highlight' => 'components.home.product-highlight', 'new-arrivals' => 'components.home.new-arrivals', 'brand-home' => 'components.home.brand-home-' . ($template ?? 'fashion-v1'), ]; $view = $componentMap[$component] ?? null; if (!$view) { return response()->json(['error' => 'Component not found'], 404); } // For brand-home component, we need to pass the template parameter if ($component === 'brand-home') { return view($view, ['template' => $template]); } return view($view); } }