This commit is contained in:
2023-04-21 10:24:04 +08:00
parent 02a29a348e
commit 0710c94a79
+7 -1
View File
@@ -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;
}
';