Commit c6773ab9 authored by shajiaiming's avatar shajiaiming

fix

parent 3eee34b1
...@@ -52,23 +52,40 @@ class Notice extends BaseActiveRecord ...@@ -52,23 +52,40 @@ 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 ($count >= 3) { if ('create' == self::getScenario()) {
if ($count == 3) {
$this->addError($attribute, '滚动公告最多只能3条');
return false;
}
}
if ('update' == self::getScenario()) {
if ($count > 3) {
$this->addError($attribute, '滚动公告最多只能3条'); $this->addError($attribute, '滚动公告最多只能3条');
return false; return false;
} }
} }
}
if (Notice::TYPE_POP == $this->type) { if (Notice::TYPE_POP == $this->type) {
if ($count >= 1) { if ('create' == self::getScenario()) {
$this->addError($attribute, '弹窗公告最多只能3条'); if ($count == 1) {
$this->addError($attribute, '弹窗公告最多只能1条');
return false; 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