调整logicTrait 基类

This commit is contained in:
liaofei 2019-11-19 16:19:25 +08:00
parent 2e6ed45f60
commit a9dc22ddc0

View File

@ -151,6 +151,8 @@ trait LogicTrait
$attribute = lcfirst(str_replace('set', '', $method));
if (property_exists($this, $attribute) && in_array($attribute, $propsRuleKeys)) {
$propsRuleValeu = $this->propsRule[$attribute];
$valeu = null;
if (is_array($propsRuleValeu)) {
$type = $propsRuleValeu[1] ?? 'string';
$callable = $propsRuleValeu[2] ?? null;
if ($type == 'callable' && $callable) {
@ -161,8 +163,11 @@ trait LogicTrait
} else if ($type) {
$ages[0] = $this->toType($ages[0], $type) ?? null;
}
} else {
$valeu = $propsRuleValeu;
}
$this->{$attribute} = $ages[0];
$this->{$attribute} = $ages[0] ?? $valeu;
return $this;
}
} else if (in_array($method, $keys)) {