Skip to content

Commit

Permalink
db类hidden append方法merge参数和模型保持一致
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Oct 30, 2024
1 parent 2254287 commit 5f00adb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/db/concern/ModelRelationQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 5f00adb

Please sign in to comment.