35 lines
1.0 KiB
PHP
35 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
class ComponentController extends Controller
|
|
{
|
|
public function load(Request $request, $component)
|
|
{
|
|
$template = $request->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);
|
|
}
|
|
}
|