/** * Updates an existing HostsSkillDetails model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { $emailtempaltemodel = EmailTemplates::find()->where(['email_key' => 'host_signup'])->multilingual()->one(); $admin_email = Configurations::find()->where(['key' => 'admin_email'])->one(); Yii::$app->mailer->compose('hosts-html', ['model' => $model, 'emailtempaltemodel' => $emailtempaltemodel])->setFrom($admin_email->value)->setTo($model->email)->setCc($admin_email->value)->setSubject($emailtempaltemodel->subject)->send(); return $this->redirect(['site/home']); } else { return $this->render('update', ['model' => $model, 'host_id' => $model->host_id]); } }
/** * Creates a new Subscribers model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Subscribers(); if (isset($_GET['message'])) { $message = $_GET['message']; } else { $message = ''; } if ($model->load(Yii::$app->request->post()) && $model->save()) { $emailtempaltemodel = EmailTemplates::find()->where(['email_key' => $model->type])->multilingual()->one(); $admin_email = Configurations::find()->where(['key' => 'admin_email'])->one(); Yii::$app->mailer->compose('subscribers-html', ['model' => $model, 'emailtempaltemodel' => $emailtempaltemodel])->setFrom($admin_email->value)->setTo($model->email)->setCc($admin_email->value)->setSubject($emailtempaltemodel->subject)->send(); return $this->redirect(['create', 'message' => 'you are subscribed now']); } else { return $this->render('create', ['model' => $model, 'message' => $message]); } }
/** * Finds the EmailTemplates model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return EmailTemplates the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = EmailTemplates::find()->multilingual()->andWhere(['id' => $id])->one()) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }