service->all(); // Mirror current truth: active vCenter id from module_vcenter $data['active_vcenter_id'] = vCenter::where('status', 1)->value('id'); return response()->json([ 'error' => false, 'data' => $data, ]); } /** PUT /administrator/provider/settings */ public function update(Request $request): JsonResponse { $validator = Validator::make($request->all(), [ 'default_folder' => 'sometimes|string|max:100', 'default_resource_pool' => 'sometimes|string|max:100', 'default_datastore' => 'sometimes|string|max:100', 'name' => 'sometimes|nullable|string|max:120', 'region' => 'sometimes|nullable|string|max:60', 'tags' => 'sometimes|array', 'tags.*' => 'string|max:40', ]); if ($validator->fails()) { return response()->json([ 'error' => true, 'message' => $validator->errors()->first(), ], 422); } $patch = $validator->validated(); // active_vcenter_id is read-only — strip if client sent it unset($patch['active_vcenter_id']); $merged = $this->service->merge($patch); $merged['active_vcenter_id'] = vCenter::where('status', 1)->value('id'); return response()->json([ 'error' => false, 'data' => $merged, ]); } }