From 89239cceb47e84dfbeba877add82cc15185cafa9 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 7 Dec 2016 18:18:38 +0800 Subject: [PATCH] =?UTF-8?q?Model=E7=B1=BB=E7=9A=84append=20hidden=E5=92=8C?= =?UTF-8?q?visible=20=E6=96=B9=E6=B3=95=E9=BB=98=E8=AE=A4=E4=BC=9A?= =?UTF-8?q?=E5=92=8C=E5=B1=9E=E6=80=A7=E8=AE=BE=E7=BD=AE=E5=90=88=E5=B9=B6?= =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0=E7=AC=AC=E4=BA=8C=E4=B8=AA=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=94=A8=E4=BA=8E=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 4176a12d..2b7f3ae3 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -487,11 +487,12 @@ abstract class Model implements \JsonSerializable, \ArrayAccess * 设置需要追加的输出属性 * @access public * @param array $append 属性列表 + * @param bool $override 是否覆盖 * @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; } @@ -499,22 +500,24 @@ abstract class Model implements \JsonSerializable, \ArrayAccess * 设置需要隐藏的输出属性 * @access public * @param array $hidden 属性列表 + * @param bool $override 是否覆盖 * @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; } /** * 设置需要输出的属性 * @param array $visible + * @param bool $override 是否覆盖 * @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; }