Blame view

frontend/controllers/SubscribeController.php 903 Bytes
ecf49b1b   Administrator   second
1
2
3
4
5
6
7
8
9
  <?php
  
  namespace frontend\controllers;
  
  use Yii;
  use yii\web\Controller;
  use common\models\Subscribe;
  use yii\web\HttpException;
  use yii\data\Pagination;
90a6ed1a   Administrator   basket
10
11
  use yii\web\Response;
  use yii\widgets\ActiveForm;
ecf49b1b   Administrator   second
12
13
14
15
16
17
18
  
  class SubscribeController extends Controller
  {
  
      public function actionIndex()
      {
  		$model = new Subscribe;
90a6ed1a   Administrator   basket
19
20
21
22
23
24
25
26
27
28
29
          if (Yii::$app->request->isAjax) {
              Yii::$app->response->format = Response::FORMAT_JSON;
              $model->load(Yii::$app->request->post());
              return ActiveForm::validate($model);
          } else {
              if ($model->load(Yii::$app->request->post()) && $model->save()) {
  
                  Yii::$app->getSession()->setFlash('success', 'Вы успешно подписались на рассылку!');
                  return $this->refresh();
              }
          }
ecf49b1b   Administrator   second
30
  
ecf49b1b   Administrator   second
31
32
33
34
          return $this->render('index',['model'=>$model]);        
      }
      
  }