/** * @inheritdoc */ public function beforeSave($insert) { if (parent::beforeSave($insert)) { //если модератор исправил текст сообщения пользователя, ставим moderator = true $oldComment = $this->findOne($this->id); if ($this->scenario == 'admin-update' && $oldComment->content !== $this->content) { $this->moderator = true; } return true; } else { return false; } }
/** * @inheritdoc */ public function beforeSave($insert) { if (parent::beforeSave($insert)) { if ($insert) { if (!$this->author_id) { $this->author_id = Yii::$app->user->id; } if (!$this->status_id) { $this->status_id = self::STATUS_ACTIVE; } } return true; } else { return false; } }