diff --git a/library/think/Model.php b/library/think/Model.php index ae4f2993..47fdc502 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -367,6 +367,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess */ protected function writeTransform($value, $type) { + if (is_null($value)) { + return null; + } + if (is_array($type)) { list($type, $param) = $type; } elseif (strpos($type, ':')) { @@ -475,6 +479,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess */ protected function readTransform($value, $type) { + if (is_null($value)) { + return null; + } + if (is_array($type)) { list($type, $param) = $type; } elseif (strpos($type, ':')) {