Commit c6773ab9 authored by shajiaiming's avatar shajiaiming

fix

parent 3eee34b1
...@@ -52,22 +52,39 @@ class Notice extends BaseActiveRecord ...@@ -52,22 +52,39 @@ class Notice extends BaseActiveRecord
public function verfiyType($attribute, $params) public function verfiyType($attribute, $params)
{ {
if ('create' == self::getScenario()) { $count = self::find()->where(['platform_id' => $this->platform_id, 'type' => $this->type])->count();
$count = self::find()->where(['platform_id' => $this->platform_id, 'type' => $this->type])->count(); if (Notice::TYPE_ROLL == $this->type) {
if (Notice::TYPE_ROLL == $this->type) { if ('create' == self::getScenario()) {
if ($count >= 3) { if ($count == 3) {
$this->addError($attribute, '滚动公告最多只能3条'); $this->addError($attribute, '滚动公告最多只能3条');
return false; return false;
} }
} }
if (Notice::TYPE_POP == $this->type) { if ('update' == self::getScenario()) {
if ($count >= 1) { if ($count > 3) {
$this->addError($attribute, '弹窗公告最多只能3条'); $this->addError($attribute, '滚动公告最多只能3条');
return false; return false;
} }
} }
} }
if (Notice::TYPE_POP == $this->type) {
if ('create' == self::getScenario()) {
if ($count == 1) {
$this->addError($attribute, '弹窗公告最多只能1条');
return false;
}
}
if ('update' == self::getScenario()) {
if ($count > 1) {
$this->addError($attribute, '弹窗公告最多只能1条');
return false;
}
}
}
} }
public function scenarios() public function scenarios()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment