From a9dc22ddc0fe011858a9400964b0462026daeb25 Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Tue, 19 Nov 2019 16:19:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4logicTrait=20=E5=9F=BA?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/crmeb/traits/LogicTrait.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/crmeb/crmeb/traits/LogicTrait.php b/crmeb/crmeb/traits/LogicTrait.php index 73a12e5f..c818d4c4 100644 --- a/crmeb/crmeb/traits/LogicTrait.php +++ b/crmeb/crmeb/traits/LogicTrait.php @@ -151,18 +151,23 @@ trait LogicTrait $attribute = lcfirst(str_replace('set', '', $method)); if (property_exists($this, $attribute) && in_array($attribute, $propsRuleKeys)) { $propsRuleValeu = $this->propsRule[$attribute]; - $type = $propsRuleValeu[1] ?? 'string'; - $callable = $propsRuleValeu[2] ?? null; - if ($type == 'callable' && $callable) { - $callable = $propsRuleValeu[2]; - if (method_exists($this, $callable)) - $ages[0] = $this->{$callable}($ages[0], $ages[1] ?? ''); + $valeu = null; + if (is_array($propsRuleValeu)) { + $type = $propsRuleValeu[1] ?? 'string'; + $callable = $propsRuleValeu[2] ?? null; + if ($type == 'callable' && $callable) { + $callable = $propsRuleValeu[2]; + if (method_exists($this, $callable)) + $ages[0] = $this->{$callable}($ages[0], $ages[1] ?? ''); - } else if ($type) { - $ages[0] = $this->toType($ages[0], $type) ?? null; + } 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)) {