feat: implement VMware vCenter integration, enhance product pricing display, and update order processing logic.

This commit is contained in:
pbao9
2026-03-01 23:10:35 +07:00
parent 6b18c3ff12
commit 1cfcaee871
27 changed files with 1738 additions and 104 deletions
@@ -178,4 +178,57 @@ class ServiceController extends Controller
'data' => new ServiceResource($product),
]);
}
/**
* Get addons for a specific product
* GET /v1/products/{productId}/addons
*/
public function getProductAddons(Request $request, string $productId)
{
$product = Product::where('uuid', $productId)->first();
if (!$product) {
return response()->json([
'error' => true,
'message' => 'Sản phẩm không tồn tại'
], 404);
}
$addons = $product->addons()
->where('status', true)
->get();
$groupedAddons = [
'cpu' => [],
'ram' => [],
'disk' => [],
'other' => []
];
foreach ($addons as $addon) {
// Group by code field (cpu, ram, disk, gpu, bandwidth, etc.)
$key = strtolower(trim($addon->code));
if (!in_array($key, ['cpu', 'ram', 'disk'])) {
$key = 'other';
}
$groupedAddons[$key][] = [
'id' => $addon->id,
'name' => $addon->name,
'type' => $addon->type,
'code' => $addon->code,
'price' => $addon->price,
'description' => $addon->description,
'min' => $addon->min,
'max' => $addon->max,
'step' => $addon->step,
'prefix' => $addon->prefix,
];
}
return response()->json([
'error' => false,
'message' => 'Lấy dữ liệu thành công',
'data' => $groupedAddons
]);
}
}