Skip to content

Commit

Permalink
属性列表支持合并
Browse files Browse the repository at this point in the history
  • Loading branch information
big-dream committed Jan 26, 2024
1 parent 99cee09 commit f760722
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/db/concern/ModelRelationQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,28 @@ public function getModel()
* 设置需要隐藏的输出属性.
*
* @param array $hidden 属性列表
* @param bool $merge 是否合并
*
* @return $this
*/
public function hidden(array $hidden = [])
public function hidden(array $hidden = [], bool $merge = false)
{
$this->options['hidden'] = $hidden;
$this->options['hidden'] = $merge ? array_merge($this->options['hidden'], $hidden) : $hidden;

return $this;
}

/**
* 设置需要输出的属性.
*
* @param array $visible
* @param array $visible 属性列表
* @param bool $merge 是否合并
*
* @return $this
*/
public function visible(array $visible = [])
public function visible(array $visible = [], bool $merge = false)
{
$this->options['visible'] = $visible;
$this->options['visible'] = $merge ? array_merge($this->options['visible'], $visible) : $visible;

return $this;
}
Expand All @@ -86,12 +88,13 @@ public function visible(array $visible = [])
* 设置需要附加的输出属性.
*
* @param array $append 属性列表
* @param bool $merge 是否合并
*
* @return $this
*/
public function append(array $append = [])
public function append(array $append = [], bool $merge = false)
{
$this->options['append'] = $append;
$this->options['append'] = $merge ? array_merge($this->options['append'], $append) : $append;

return $this;
}
Expand Down

0 comments on commit f760722

Please sign in to comment.