Blame view

frontend/controllers/SupportController.php 1.17 KB
e47109b0   Anastasia   - support
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  <?php
      /**
       * Created by PhpStorm.
       * User: stes
       * Date: 14.06.18
       * Time: 13:40
       */
      
      namespace frontend\controllers;
      
      use common\models\Book;
      use common\models\Support;
      use yii\web\Controller;
  
      class SupportController extends Controller
      {
          public function actionIndex($book_id = null){
              $model = new Support([
                  'book_id' => $book_id,
                  'status'  => 0
                                   ]);
              $book = Book::find()->with('author')->where(['id' => $book_id])->one();
              if ($model->load(\Yii::$app->request->post()) and $model->save()){
                  \Yii::$app->session->setFlash('success', 'Дякуємо за ваш запит. Найближчим часом, наш менеджер зв\'яжеться з Вами для уточнення деталей');
                  return $this->redirect(['site/index']);
              }
              return $this->render('index', [
                  'model' => $model,
                  'book' => $book
              ]);
          }
6a07bb2b   Виталий   support form
32
33
34
35
36
  
          public function actionSearch()
          {
              return $this->render('search');
          }
e47109b0   Anastasia   - support
37
      }