예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Email::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
예제 #2
0
 public function actionCreateFromUser()
 {
     $model = new Review();
     if (Yii::$app->request->isPost) {
         $model->load(Yii::$app->request->post());
         $model->scenario = 'accept';
         $model->save();
         //$model->validate();
         //vd($model->getErrors());
         // Todo отправка ел почты
         $model_Email = Email::find()->where(['id' => 1])->one();
         $currEmail = $model_Email->email;
         Yii::$app->mailer->compose(['html' => 'review'], ['model' => $model])->setFrom($model->email)->setTo($currEmail)->setSubject('CОБЩЕНИЕ VinnieGuitar - Новый отзыв')->setTextBody('<b>HTML content</b>')->send();
         Yii::$app->getSession()->setFlash('success', 'Ваш отзыв принят!');
         return $this->redirect('/site/review');
     } else {
         Yii::$app->getSession()->setFlash('error', 'Ошибка! Ваш отзыв не принят!');
         return $this->redirect('/site/review', ['model' => $model]);
     }
 }
예제 #3
0
 /**
  * Finds the Email model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Email the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Email::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #4
0
 public function actionSubmit()
 {
     $model = new Order();
     $model->scenario = 'submit';
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $model->save();
         //ToDo отправка сообщения по почте
         $model_Email = Email::find()->where(['id' => 1])->one();
         $currEmail = $model_Email->email;
         if ($model->save()) {
             Yii::$app->mailer->compose(['html' => 'order'], ['model' => $model])->setFrom($model->email)->setTo($currEmail)->setSubject('CОБЩЕНИЕ VinnieGuitar - Новый заказ')->setTextBody('<b>HTML content</b>')->send();
             Yii::$app->getSession()->setFlash('success', 'Ваш заказ принят!');
             return $this->redirect(\Yii::$app->request->getReferrer());
         } else {
             Yii::$app->getSession()->setFlash('error', 'Ошибка . Ваш заказ не принят!');
             // либо страница отображается первый раз, либо есть ошибка в данных
             return $this->redirect(\Yii::$app->request->getReferrer());
         }
     }
 }