mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 07:02:47 +08:00
Model类的append hidden和visible 方法默认会和属性设置合并 增加第二个参数用于覆盖
This commit is contained in:
@@ -487,11 +487,12 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
* 设置需要追加的输出属性
|
* 设置需要追加的输出属性
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $append 属性列表
|
* @param array $append 属性列表
|
||||||
|
* @param bool $override 是否覆盖
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function append($append = [])
|
public function append($append = [], $override = false)
|
||||||
{
|
{
|
||||||
$this->append = $append;
|
$this->append = $override ? $append : array_merge($this->append, $append);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,22 +500,24 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
* 设置需要隐藏的输出属性
|
* 设置需要隐藏的输出属性
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $hidden 属性列表
|
* @param array $hidden 属性列表
|
||||||
|
* @param bool $override 是否覆盖
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function hidden($hidden = [])
|
public function hidden($hidden = [], $override = false)
|
||||||
{
|
{
|
||||||
$this->hidden = $hidden;
|
$this->hidden = $override ? $hidden : array_merge($this->hidden, $hidden);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置需要输出的属性
|
* 设置需要输出的属性
|
||||||
* @param array $visible
|
* @param array $visible
|
||||||
|
* @param bool $override 是否覆盖
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function visible($visible = [])
|
public function visible($visible = [], $override = false)
|
||||||
{
|
{
|
||||||
$this->visible = $visible;
|
$this->visible = $override ? $visible : array_merge($this->visible, $visible);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user