/** * Creates a new Review model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Review(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public function actionReviewCreate() { $model = new Review(); $products = Product::find()->where(['top' => Product::STATUS_TOP, 'category_id' => 1])->all(); if ($model->load(Yii::$app->request->post()) && $model->save()) { $model->sendEmail('Новый Отзыв', 'review'); Yii::$app->session->addFlash('success', 'Спасибо за Ваш отзыв! Отзыв проходит модерацию.'); return $this->goHome(); } else { return $this->render('index', ['review' => $model, 'products' => $products]); } }