update layout control vm

This commit is contained in:
Pham Bao
2025-08-10 22:19:22 +07:00
parent 3ef83f8662
commit 8758927c1d
6 changed files with 112 additions and 12 deletions
@@ -794,6 +794,60 @@ class ServiceController extends Controller
}
}
/**
* Renew service for selected months
*/
public function renew(Request $request)
{
try {
$user = customer();
if (!$user) {
return response()->json([
'error' => true,
'message' => __('Chưa đăng nhập. Vui lòng đăng nhập để sử dụng tính năng này.'),
], 401);
}
$validated = FacadesValidator::make($request->all(), [
'product_id' => 'required|string|max:255',
'plan' => 'required|string|in:3,6,12,24,other',
'months' => 'nullable|integer|min:1|max:60',
]);
if ($validated->fails()) {
return response()->json([
'error' => true,
'message' => __('Dữ liệu không hợp lệ'),
'errors' => $validated->errors(),
], 422);
}
$months = $request->plan === 'other' ? (int) ($request->months ?? 1) : (int) $request->plan;
$productId = $this->sanitizeInput($request->product_id);
Log::info('Khách yêu cầu gia hạn dịch vụ', [
'user_id' => $user->id,
'product_vmware_id' => $productId,
'months' => $months,
]);
// TODO: implement actual renewal billing/workflow
return response()->json([
'error' => false,
'message' => __('Yêu cầu gia hạn đã được ghi nhận'),
]);
} catch (\Exception $e) {
Log::error('Lỗi renew', [
'user_id' => customer()?->id,
'error' => $e->getMessage(),
]);
return response()->json([
'error' => true,
'message' => __('Có lỗi xảy ra khi gia hạn'),
], 500);
}
}
/**
* Secure remove snapshot using session authentication - NO BEARER TOKEN
*/