mirror of
https://gitee.com/wonderful-code/buildadmin
synced 2024-11-22 07:04:24 +00:00
refactor(CRUD):完善模型设置器和获取器的类型定义
This commit is contained in:
parent
7a25845155
commit
aa589ff052
@ -587,6 +587,10 @@ class Crud extends Backend
|
||||
$modelData['methods'][] = Helper::assembleStub('mixins/model/getters/htmlDecode', [
|
||||
'field' => $fieldName
|
||||
]);
|
||||
} elseif ($field['originalDesignType'] == 'float') {
|
||||
$modelData['methods'][] = Helper::assembleStub('mixins/model/getters/float', [
|
||||
'field' => $fieldName
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -553,7 +553,8 @@ class Helper
|
||||
*/
|
||||
public static function analyseField(&$field)
|
||||
{
|
||||
$field['type'] = self::analyseFieldType($field);
|
||||
$field['type'] = self::analyseFieldType($field);
|
||||
$field['originalDesignType'] = $field['designType'];
|
||||
|
||||
// 表单项类型转换对照表
|
||||
$designTypeComparison = [
|
||||
|
@ -0,0 +1,5 @@
|
||||
|
||||
public function get{%field%}Attr($value): float
|
||||
{
|
||||
return (float)$value;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
|
||||
public function get{%field%}Attr($value)
|
||||
public function get{%field%}Attr($value): string
|
||||
{
|
||||
return !$value ? '' : htmlspecialchars_decode($value);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
|
||||
public function get{%field%}Attr($value)
|
||||
public function get{%field%}Attr($value): array
|
||||
{
|
||||
return !$value ? [] : json_decode($value, true);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
|
||||
public function get{%field%}Attr($value)
|
||||
public function get{%field%}Attr($value): array
|
||||
{
|
||||
if (!$value) return [];
|
||||
if (!is_array($value)) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
public function set{%field%}Attr($value)
|
||||
public function set{%field%}Attr($value): string
|
||||
{
|
||||
return $value ? (is_array($value) ? implode(',', $value) : $value) : '';
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
|
||||
public function set{%field%}Attr($value)
|
||||
public function set{%field%}Attr($value): string
|
||||
{
|
||||
return $value ? date('H:i:s', strtotime($value)) : '';
|
||||
}
|
Loading…
Reference in New Issue
Block a user