Skip to content

Commit 5f00adb

Browse files
committed
db类hidden append方法merge参数和模型保持一致
1 parent 2254287 commit 5f00adb

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/db/concern/ModelRelationQuery.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function getModel()
6464
*/
6565
public function hidden(array $hidden = [], bool $merge = false)
6666
{
67-
$this->options['hidden'] = $merge ? array_merge($this->options['hidden'], $hidden) : $hidden;
67+
$this->options['hidden'] = [$hidden, $merge];
6868

6969
return $this;
7070
}
@@ -79,7 +79,7 @@ public function hidden(array $hidden = [], bool $merge = false)
7979
*/
8080
public function visible(array $visible = [], bool $merge = false)
8181
{
82-
$this->options['visible'] = $merge ? array_merge($this->options['visible'], $visible) : $visible;
82+
$this->options['visible'] = [$visible, $merge];
8383

8484
return $this;
8585
}
@@ -94,7 +94,7 @@ public function visible(array $visible = [], bool $merge = false)
9494
*/
9595
public function append(array $append = [], bool $merge = false)
9696
{
97-
$this->options['append'] = $merge ? array_merge($this->options['append'], $append) : $append;
97+
$this->options['append'] = [$append, $merge];
9898

9999
return $this;
100100
}
@@ -693,7 +693,8 @@ protected function resultToModel(array &$result): void
693693

694694
foreach (['hidden', 'visible', 'append'] as $name) {
695695
if (isset($this->options[$name])) {
696-
$result->$name($this->options[$name]);
696+
[$value, $merge] = $this->options[$name];
697+
$result->$name($value, $merge);
697698
}
698699
}
699700

0 commit comments

Comments
 (0)