update rm deadcode

This commit is contained in:
baodev0
2026-09-27 11:42:40 +07:00
parent 82a71244ca
commit 3af59bd9c5
129 changed files with 5194 additions and 2698 deletions
@@ -9,7 +9,7 @@ use Illuminate\Http\Request;
trait ResolvesVm
{
protected function resolveVmById(int|string $productId, Request $request): ModuleVmware|JsonResponse
protected function resolveVmById(int|string $productId, Request $request, bool $requireActiveService = true): ModuleVmware|JsonResponse
{
$customer = $request->user();
$vm = null;
@@ -42,6 +42,13 @@ trait ResolvesVm
return response()->json(['error' => true, 'message' => 'Bạn không có quyền thao tác VM này'], 403);
}
if ($requireActiveService) {
$service = $vm->service ?? Service::where('vm_id', $vm->vmware_id)->first();
if ($service && $service->status !== 'active') {
return response()->json(['error' => true, 'message' => 'Dịch vụ không ở trạng thái hoạt động, không thể thao tác.'], 403);
}
}
return $vm;
}