/** * @var Promotion $model * * @param integer $id * * @throws \yii\web\NotFoundHttpException */ public function actionRejected($id) { $model = $this->findModel($id); $model->status = Promotion::REJECTED; $model->save(); $text = Yii::$app->request->post('text', false); if ($text === false) { echo 1; } else { $rejectedComment = new RejectedCommentAuto(); $rejectedComment->text = $text; $rejectedComment->promotion_id = $model->id; $rejectedComment->date = time(); if ($rejectedComment->save()) { echo 1; } else { echo 0; } } }
public function getRejectedCommentAuto() { return $this->hasMany(RejectedCommentAuto::className(), ['promotion_id' => 'id']); }