From 5f00adb2eda3ccd6542ea6b591f88e4b0ea8c93c Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 30 Oct 2024 18:01:52 +0800 Subject: [PATCH] =?UTF-8?q?db=E7=B1=BBhidden=20append=E6=96=B9=E6=B3=95mer?= =?UTF-8?q?ge=E5=8F=82=E6=95=B0=E5=92=8C=E6=A8=A1=E5=9E=8B=E4=BF=9D?= =?UTF-8?q?=E6=8C=81=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/db/concern/ModelRelationQuery.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/db/concern/ModelRelationQuery.php b/src/db/concern/ModelRelationQuery.php index e6d92531..1cac4c5a 100644 --- a/src/db/concern/ModelRelationQuery.php +++ b/src/db/concern/ModelRelationQuery.php @@ -64,7 +64,7 @@ public function getModel() */ public function hidden(array $hidden = [], bool $merge = false) { - $this->options['hidden'] = $merge ? array_merge($this->options['hidden'], $hidden) : $hidden; + $this->options['hidden'] = [$hidden, $merge]; return $this; } @@ -79,7 +79,7 @@ public function hidden(array $hidden = [], bool $merge = false) */ public function visible(array $visible = [], bool $merge = false) { - $this->options['visible'] = $merge ? array_merge($this->options['visible'], $visible) : $visible; + $this->options['visible'] = [$visible, $merge]; return $this; } @@ -94,7 +94,7 @@ public function visible(array $visible = [], bool $merge = false) */ public function append(array $append = [], bool $merge = false) { - $this->options['append'] = $merge ? array_merge($this->options['append'], $append) : $append; + $this->options['append'] = [$append, $merge]; return $this; } @@ -693,7 +693,8 @@ protected function resultToModel(array &$result): void foreach (['hidden', 'visible', 'append'] as $name) { if (isset($this->options[$name])) { - $result->$name($this->options[$name]); + [$value, $merge] = $this->options[$name]; + $result->$name($value, $merge); } }