From 3f02c0547e880ad50e626cb68f4e913f05f75036 Mon Sep 17 00:00:00 2001 From: haomingming Date: Fri, 26 Dec 2025 13:36:20 +0800 Subject: [PATCH] 666 --- app/Services/PatientOrderService.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Services/PatientOrderService.php b/app/Services/PatientOrderService.php index a2a8521..80a000b 100644 --- a/app/Services/PatientOrderService.php +++ b/app/Services/PatientOrderService.php @@ -2023,8 +2023,9 @@ class PatientOrderService extends BaseService 'user_name' => $UserDoctor['user_name'] ?? null, 'doctor_title' => $UserDoctor['doctor_title'] ?? null, ]); - // 使用 setRelation 方法确保关联对象正确设置 + // 同时使用 setRelation 和数组赋值,确保无论是通过关系访问还是数组访问都能获取到新对象 $item->setRelation('UserDoctor', $UserDoctor); + $item['UserDoctor'] = $UserDoctor; } } } @@ -2035,8 +2036,9 @@ class PatientOrderService extends BaseService if (is_object($userDoctor)) { // 使用对象属性语法修改 $userDoctor->doctor_title = DoctorTitleCode::getMessage($userDoctor->doctor_title); - // 确保修改后的对象重新设置到关系中 + // 确保修改后的对象同时设置到关系和数组中 $item->setRelation('UserDoctor', $userDoctor); + $item['UserDoctor'] = $userDoctor; } else { // 如果是数组,直接修改数组 $item['UserDoctor']['doctor_title'] = DoctorTitleCode::getMessage($item['UserDoctor']['doctor_title']);