防止非查询字段而导致的append报错的问题

pull/68/head
terranc 2018-07-20 07:40:35 +08:00
parent 3683728023
commit fde144057d
5 changed files with 38 additions and 18 deletions

View File

@ -1,8 +1,12 @@
public function {%methodName%}($value, $data) public function {%methodName%}($value, $data)
{ {
$value = $value ? $value : $data['{%field%}']; if (isset($data['{%field%}')) {
$valueArr = explode(',', $value); $value = $value ? $value : $data['{%field%}'];
$list = $this->{%listMethodName%}(); $valueArr = explode(',', $value);
return implode(',', array_intersect_key($list, array_flip($valueArr))); $list = $this->{%listMethodName%}();
return implode(',', array_intersect_key($list, array_flip($valueArr)));
} else {
return '';
}
} }

View File

@ -1,6 +1,10 @@
public function {%methodName%}($value, $data) public function {%methodName%}($value, $data)
{ {
$value = $value ? $value : $data['{%field%}']; if (isset($data['{%field%}')) {
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; $value = $value ? $value : $data['{%field%}'];
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
} else {
return $value;
}
} }

View File

@ -1,8 +1,12 @@
public function {%methodName%}($value, $data) public function {%methodName%}($value, $data)
{ {
$value = $value ? $value : $data['{%field%}']; if (isset($data['{%field%}')) {
$valueArr = explode(',', $value); $value = $value ? $value : $data['{%field%}'];
$list = $this->{%listMethodName%}(); $valueArr = explode(',', $value);
return implode(',', array_intersect_key($list, array_flip($valueArr))); $list = $this->{%listMethodName%}();
return implode(',', array_intersect_key($list, array_flip($valueArr)));
} else {
return '';
}
} }

View File

@ -1,7 +1,11 @@
public function {%methodName%}($value, $data) public function {%methodName%}($value, $data)
{ {
$value = $value ? $value : $data['{%field%}']; if (isset($data['{%field%}')) {
$list = $this->{%listMethodName%}(); $value = $value ? $value : $data['{%field%}'];
return isset($list[$value]) ? $list[$value] : ''; $list = $this->{%listMethodName%}();
return isset($list[$value]) ? $list[$value] : '';
} else {
return '';
}
} }

View File

@ -1,7 +1,11 @@
public function {%methodName%}($value, $data) public function {%methodName%}($value, $data)
{ {
$value = $value ? $value : $data['{%field%}']; if (isset($data['{%field%}')) {
$list = $this->{%listMethodName%}(); $value = $value ? $value : $data['{%field%}'];
return isset($list[$value]) ? $list[$value] : ''; $list = $this->{%listMethodName%}();
return isset($list[$value]) ? $list[$value] : '';
} else {
return '';
}
} }