From 6d6ac98bfa5f13856b06a407cbdade5acc98f87f Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 28 Oct 2024 13:31:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/model/relation/BelongsToMany.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/model/relation/BelongsToMany.php b/src/model/relation/BelongsToMany.php index eca32159..7c5a7299 100644 --- a/src/model/relation/BelongsToMany.php +++ b/src/model/relation/BelongsToMany.php @@ -192,10 +192,10 @@ protected function matchPivot(Model $result): array if ('pivot' == $name) { $pivot[$attr] = $val; if (isset($bindAttr[$attr])) { - $attr = $bindAttr[$attr]; - $result->$attr = $val; - } elseif (array_search($attr, $bindAttr)) { - $result->$attr = $val; + $attr = $bindAttr[$attr]; + $result->setAttr($attr, $val); + } elseif (false !== array_search($attr, $bindAttr)) { + $result->setAttr($attr, $val); } unset($result->$key); }