add
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
|
||||
public function get{%field%}Attr($value, $row): string
|
||||
{
|
||||
if ($row['{%originalFieldName%}'] === '' || $row['{%originalFieldName%}'] === null) return '';
|
||||
$cityNames = \think\facade\Db::name('area')->whereIn('id', $row['{%originalFieldName%}'])->column('name');
|
||||
return $cityNames ? implode(',', $cityNames) : '';
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
public function get{%field%}Attr($value): ?float
|
||||
{
|
||||
return is_null($value) ? null : (float)$value;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
public function get{%field%}Attr($value): string
|
||||
{
|
||||
return !$value ? '' : htmlspecialchars_decode($value);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
public function get{%field%}Attr($value): array
|
||||
{
|
||||
return !$value ? [] : json_decode($value, true);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
public function get{%field%}Attr($value, $row): array
|
||||
{
|
||||
return [
|
||||
'{%labelFieldName%}' => {%className%}::whereIn('{%primaryKey%}', $row['{%foreignKey%}'])->column('{%labelFieldName%}'),
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
public function get{%field%}Attr($value): string
|
||||
{
|
||||
return (string)$value;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
public function get{%field%}Attr($value): array
|
||||
{
|
||||
if ($value === '' || $value === null) return [];
|
||||
if (!is_array($value)) {
|
||||
return explode(',', $value);
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
Reference in New Issue
Block a user