From 3258d6071d57ef9c8f9a8f78b5765ee058740c67 Mon Sep 17 00:00:00 2001 From: liutong <836164388@qq.com> Date: Fri, 30 May 2025 18:08:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(customer-resources):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=88=86=E4=BA=AB=E5=85=B3=E8=81=94=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 CustomerResources 模型中添加 resourceSharingHasMany 方法,实现一对多关联资源共享表 - 在 CustomerResourcesService 中使用 with 方法预加载资源分享关联数据 --- .../app/model/customer_resources/CustomerResources.php | 9 +++++++++ .../service/api/apiService/CustomerResourcesService.php | 3 +++ 2 files changed, 12 insertions(+) diff --git a/niucloud/app/model/customer_resources/CustomerResources.php b/niucloud/app/model/customer_resources/CustomerResources.php index cd2e4f79..3e83166f 100644 --- a/niucloud/app/model/customer_resources/CustomerResources.php +++ b/niucloud/app/model/customer_resources/CustomerResources.php @@ -153,6 +153,15 @@ class CustomerResources extends BaseModel return $this->hasOne(SixSpeed::class, 'resource_id', 'id'); } + //一对多关联"资源共享表" + public function resourceSharingHasMany() + { + return $this->hasMany(ResourceSharing::class, 'resource_id', 'id'); + } + + + + /** * 获取客户初步意向度类型名称 * @param $value diff --git a/niucloud/app/service/api/apiService/CustomerResourcesService.php b/niucloud/app/service/api/apiService/CustomerResourcesService.php index fa33da12..7c3e77a9 100644 --- a/niucloud/app/service/api/apiService/CustomerResourcesService.php +++ b/niucloud/app/service/api/apiService/CustomerResourcesService.php @@ -52,6 +52,9 @@ class CustomerResourcesService extends BaseApiService $model = $model->where('name', 'like', "%{$where['name']}%"); } $data = $model->field($field) + ->with([ + 'resourceSharingHasMany' + ]) ->append([ 'initial_intent_name' ])