From 7490f0972ad18ae070d996b1da390554646625e0 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Thu, 20 Feb 2025 17:19:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E5=85=B3=E8=81=94=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/relation/BelongsTo.php | 7 +------ src/model/relation/HasOne.php | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/model/relation/BelongsTo.php b/src/model/relation/BelongsTo.php index a9909c9a..6e4548f9 100644 --- a/src/model/relation/BelongsTo.php +++ b/src/model/relation/BelongsTo.php @@ -70,7 +70,7 @@ public function getRelation(array $subRelation = [], ?Closure $closure = null) if ($relationModel) { if (!empty($this->bindAttr)) { // 绑定关联属性 - $this->bindAttr($this->parent, $relationModel); + $this->parent->bindRelationAttr($relationModel, $this->bindAttr); } $relationModel->setParent(clone $this->parent); @@ -258,11 +258,6 @@ protected function eagerlySet(array &$resultSet, string $relation, array $subRel $result->bindRelationAttr($relationModel, $this->bindAttr); } else { $result->setRelation($relation, $relationModel); - if (!empty($this->bindAttr)) { - // 绑定关联属性 - $this->bindAttr($result, $relationModel); - $result->hidden([$relation], true); - } } } } diff --git a/src/model/relation/HasOne.php b/src/model/relation/HasOne.php index 1efe846e..62285df0 100644 --- a/src/model/relation/HasOne.php +++ b/src/model/relation/HasOne.php @@ -70,7 +70,7 @@ public function getRelation(array $subRelation = [], ?Closure $closure = null) if ($relationModel) { if (!empty($this->bindAttr)) { // 绑定关联属性 - $this->bindAttr($this->parent, $relationModel); + $this->parent->bindRelationAttr($relationModel, $this->bindAttr); } $relationModel->setParent(clone $this->parent);