/** * Creates a new Request model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Request(); 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 actionRequest($type) { $this->layout = '/default'; $model = new Request(); $model->type = $type; if ($model->load($_POST) && $model->save()) { $title = 'Новая заявка на получение карты на сайте: ' . Yii::$app->name; Yii::$app->session->setFlash('success', 'Ваша заявка успешно создана.'); $email = Yii::$app->params['email']; if (Yii::$app->mailer->compose('@app/modules/discount/views/default/mail/request', ['model' => $model, 'title' => $title])->setFrom($email->from)->setTo($email->to)->setSubject($title)->send()) { $this->redirect(['/cms/default/success']); } } else { return $this->render('request', ['model' => $model]); } }