From ba4c5d39b4f80d8cee1588a5fa1d03107422714c Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 30 Jan 2017 08:33:55 +0800 Subject: [PATCH] =?UTF-8?q?Model=E7=B1=BB=E5=A2=9E=E5=8A=A0readonly?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/library/think/Model.php b/library/think/Model.php index 86fcb88d..7a488c95 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -1018,6 +1018,21 @@ abstract class Model implements \JsonSerializable, \ArrayAccess return $this; } + /** + * 设置只读字段 + * @access public + * @param mixed $field 只读字段 + * @return $this + */ + public function readonly($field) + { + if (is_string($field)) { + $field = explode(',', $field); + } + $this->readonly = $field; + return $this; + } + /** * 是否为更新数据 * @access public