Blame view

frontend/controllers/SearchController.php 2.76 KB
fbdb1f1c   Yarik   test
1
2
3
  <?php
  namespace frontend\controllers;
  
6dd6c4bf   Administrator   17.02.16
4
  use common\models\Project;
eb7e82fb   Administrator   29.02.16
5
6
  use common\models\UserInfo;
  use common\models\Vacancy;
fbdb1f1c   Yarik   test
7
8
9
10
11
12
13
14
15
  use Yii;
  use common\models\LoginForm;
  use frontend\models\PasswordResetRequestForm;
  use frontend\models\ResetPasswordForm;
  use frontend\models\SignupForm;
  use frontend\models\ContactForm;
  use frontend\models\Options;
  use frontend\models\OptionValues;
  use yii\base\InvalidParamException;
6dd6c4bf   Administrator   17.02.16
16
  use yii\data\ActiveDataProvider;
eb7e82fb   Administrator   29.02.16
17
  use yii\data\Pagination;
fbdb1f1c   Yarik   test
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  use yii\web\BadRequestHttpException;
  use yii\web\Controller;
  use yii\filters\VerbFilter;
  use yii\filters\AccessControl;
  use frontend\models\OptionsToValues;
  use yii\validators\EmailValidator;
  use common\models\User;
  use yii\helpers\VarDumper;
  use common\models\Page; 
  use frontend\models\Option;
  use common\models\Social;
  
  
  /**
   * Site controller
   */
  class SearchController extends Controller
  {
      public $defaultAction = 'common';
  
      /**
       * @inheritdoc
       */
      public function actions()
      {
          return [
              'error' => [
                  'class' => 'yii\web\ErrorAction',
              ],
              'captcha' => [
                  'class' => 'yii\captcha\CaptchaAction',
                  'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
              ],
          ];
      }
  
      public function actionProject()
      {
6dd6c4bf   Administrator   17.02.16
56
57
58
59
60
61
62
63
64
65
66
  
          $projects = new ActiveDataProvider([
              'query' =>  Project::find(),
              'pagination' => [
                  'pageSize' => 9,
              ],
          ]);
  
          return $this->render('project',[
              'projects' => $projects
          ]);
fbdb1f1c   Yarik   test
67
68
69
70
71
72
73
74
75
      }
  
      public function actionCompany()
      {
          return $this->render('company');
      }
  
      public function actionPerformer()
      {
eb7e82fb   Administrator   29.02.16
76
77
78
79
80
81
82
83
84
85
86
87
          $query = UserInfo::find()->where(['is_customer' => 1]);
  
          $performer = new ActiveDataProvider([
              'query' =>  $query,
              'pagination' => [
                  'pageSize' => 3,
              ],
          ]);
  
          return $this->render('performer',[
              'performer' => $performer
          ]);
fbdb1f1c   Yarik   test
88
89
      }
  
7fc05ac5   Yarik   test
90
91
      public function actionVacancy()
      {
eb7e82fb   Administrator   29.02.16
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
  
  
          $query = Vacancy::find();
  
          $countQuery = clone $query;
  
          $pagination = new Pagination(['totalCount' => $countQuery->count(),
              'pageSize' => 15,
          ]);
  
          $vacancy = $query->offset($pagination->offset)
              ->limit($pagination->limit);
  
  
          $provider = new ActiveDataProvider([
              'query' => $vacancy,
              'pagination' => false,
              'sort' => [
                  'defaultOrder' => [
                      'date_add' => SORT_DESC,
                      'name' => SORT_ASC,
                  ]
              ],
          ]);
  
  
  
          return $this->render('vacancy',[
              'provider' => $provider,
              'pagination' => $pagination
          ]);
7fc05ac5   Yarik   test
123
124
      }
  
fbdb1f1c   Yarik   test
125
  }