Blame view

frontend/controllers/ProjectsController.php 1.76 KB
eb7e82fb   Administrator   29.02.16
1
2
3
  <?php

      namespace frontend\controllers;

  

32ed90fd   Yarik   test
4
5
6
7
      use common\models\ProjectSearch;

      use common\models\User;

      use common\modules\comment\models\CommentProject;

      use common\modules\comment\models\CommentProjectSearch;

eb7e82fb   Administrator   29.02.16
8
9
10
11
12
      use yii\filters\AccessControl;

      use yii\web\Controller;

  

      class ProjectsController extends Controller

      {

32ed90fd   Yarik   test
13
  

eb7e82fb   Administrator   29.02.16
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
          public function behaviors()

          {

              return [

                  'access' => [

                      'class' => AccessControl::className(),

                      'rules' => [

                          [

                              //'actions' => ['cabinet','change-password', 'bookmarks', 'projects'],

                              'allow' => true,

                              'roles' => [ '@' ],

                          ],

                      ],

                  ],

              ];

          }

  

          public function actionIndex()

          {

32ed90fd   Yarik   test
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
              $model = new CommentProjectSearch([ 'scenario' => CommentProjectSearch::SCENARIO_SEARCH ]);

              $groups = CommentProject::find()

                                      ->select([

                                          'COUNT(*)',

                                          'state',

                                      ])

                                      ->asArray()

                                      ->indexBy('state')

                                      ->where([ 'user_id' => \Yii::$app->user->getId() ])

                                      ->groupBy([ 'state' ])

                                      ->column();

              $comments = $model->search(\Yii::$app->request->queryParams);

              return $this->render('projects', [

                  'comments' => $comments,

                  'groups'   => $groups,

              ]);

eb7e82fb   Administrator   29.02.16
48
          }

989c83b0   Yarik   test
49
      }