Commit 47bd5adef95576647b483d704bba078b21f36043
1 parent
71ad29c4
test
Showing
3 changed files
with
7 additions
and
4 deletions
Show diff stats
common/models/Project.php
common/modules/comment/models/Comment.php
@@ -310,7 +310,7 @@ | @@ -310,7 +310,7 @@ | ||
310 | 'model' => $this->className(), | 310 | 'model' => $this->className(), |
311 | ]) | 311 | ]) |
312 | ->one(); | 312 | ->one(); |
313 | - if(!$rating instanceof \common\modules\comment\models\Rating && !$this->isNewRecord) { | 313 | + if(!$rating instanceof \common\modules\comment\models\Rating && !empty($this->primaryKey)) { |
314 | $rating = new \common\modules\comment\models\Rating([ | 314 | $rating = new \common\modules\comment\models\Rating([ |
315 | 'model' => $this->className(), | 315 | 'model' => $this->className(), |
316 | 'model_id' => $this->comment_id, | 316 | 'model_id' => $this->comment_id, |
common/modules/comment/widgets/CommentWidget.php
@@ -225,8 +225,11 @@ | @@ -225,8 +225,11 @@ | ||
225 | { | 225 | { |
226 | $data = \Yii::$app->request->post(); | 226 | $data = \Yii::$app->request->post(); |
227 | if($this->comment_class->load($data) && $this->comment_class->postComment()) { | 227 | if($this->comment_class->load($data) && $this->comment_class->postComment()) { |
228 | - if(is_object($this->rating_class) && $this->comment_class->rating->load($data) && $this->comment_class->rating->save()) { | ||
229 | - $this->isSuccess = true; | 228 | + if(is_object($this->rating_class)) { |
229 | + $this->comment_class->checkRating(); | ||
230 | + if($this->comment_class->rating->load($data) && $this->comment_class->rating->save()) { | ||
231 | + $this->isSuccess = true; | ||
232 | + } | ||
230 | } | 233 | } |
231 | } | 234 | } |
232 | } | 235 | } |