From 0710c94a790bc5c56fe3c09ca4025856b857aac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Fri, 21 Apr 2023 10:24:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GiiModel.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/GiiModel.php b/GiiModel.php index 9d3ba08..40de029 100644 --- a/GiiModel.php +++ b/GiiModel.php @@ -157,6 +157,9 @@ class ' . $managerName . ' extends Model */ public function set' . ucfirst($field['Field']) . 'Attribute(?array $value): int|bool|string { + if (is_null($value)) { + $value = []; + } return \json_encode($value, JSON_UNESCAPED_UNICODE); } '; @@ -168,7 +171,10 @@ class ' . $managerName . ' extends Model */ public function get' . ucfirst($field['Field']) . 'Attribute(?string $value): array|null|bool { - return \json_decode($value, true); + if (!is_null($value)) { + return \json_decode($value, true); + } + return null; } ';