update rm deadcode
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user