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