This commit is contained in:
2023-04-21 10:24:04 +08:00
parent 02a29a348e
commit 0710c94a79
+6
View File
@@ -157,6 +157,9 @@ class ' . $managerName . ' extends Model
*/ */
public function set' . ucfirst($field['Field']) . 'Attribute(?array $value): int|bool|string public function set' . ucfirst($field['Field']) . 'Attribute(?array $value): int|bool|string
{ {
if (is_null($value)) {
$value = [];
}
return \json_encode($value, JSON_UNESCAPED_UNICODE); return \json_encode($value, JSON_UNESCAPED_UNICODE);
} }
'; ';
@@ -168,8 +171,11 @@ class ' . $managerName . ' extends Model
*/ */
public function get' . ucfirst($field['Field']) . 'Attribute(?string $value): array|null|bool public function get' . ucfirst($field['Field']) . 'Attribute(?string $value): array|null|bool
{ {
if (!is_null($value)) {
return \json_decode($value, true); return \json_decode($value, true);
} }
return null;
}
'; ';
if (!str_contains($html, 'set' . ucfirst($field['Field']) . 'Attribute')) { if (!str_contains($html, 'set' . ucfirst($field['Field']) . 'Attribute')) {