Blame view

common/models/FeedbackSearch.php 2.38 KB
d8c1a2e0   Yarik   Big commit artbox
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  <?php
      
      namespace common\models;
      
      use yii\data\ActiveDataProvider;
      
      class FeedbackSearch extends Feedback
      {
          
          /**
           * @inheritdoc
           */
          public function rules()
          {
              return [
                  [
8af13427   Yarik   For leha commit.
17
                      [ 'id' ],
d8c1a2e0   Yarik   Big commit artbox
18
19
20
21
22
23
24
                      'integer',
                  ],
                  [
                      [
                          'name',
                          'phone',
                          'ip',
8af13427   Yarik   For leha commit.
25
                          'created_at',
d8c1a2e0   Yarik   Big commit artbox
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
                      ],
                      'safe',
                  ],
              ];
          }
          
          /**
           * @inheritdoc
           */
          public function scenarios()
          {
              return Feedback::scenarios();
          }
          
          /**
           * Creates data provider instance with search query applied
           *
           * @param array $params
           *
           * @return ActiveDataProvider
           */
          public function search($params)
          {
              $query = Feedback::find();
              
              // add conditions that should always apply here
              
8af13427   Yarik   For leha commit.
53
54
55
56
57
              $dataProvider = new ActiveDataProvider(
                  [
                      'query' => $query,
                  ]
              );
d8c1a2e0   Yarik   Big commit artbox
58
59
60
              
              $this->load($params);
              
8af13427   Yarik   For leha commit.
61
              if (!$this->validate()) {
d8c1a2e0   Yarik   Big commit artbox
62
63
64
65
66
67
                  // uncomment the following line if you do not want to return any records when validation fails
                  // $query->where('0=1');
                  return $dataProvider;
              }
              
              // grid filtering conditions
8af13427   Yarik   For leha commit.
68
69
70
71
72
              $query->andFilterWhere(
                  [
                      'id' => $this->id,
                  ]
              );
d8c1a2e0   Yarik   Big commit artbox
73
              
8af13427   Yarik   For leha commit.
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
              $query->andFilterWhere(
                  [
                      'like',
                      'name',
                      $this->name,
                  ]
              )
                    ->andFilterWhere(
                        [
                            'like',
                            'phone',
                            $this->phone,
                        ]
                    )
                    ->andFilterWhere(
                        [
                            'like',
                            'ip',
                            $this->ip,
                        ]
                    );
d8c1a2e0   Yarik   Big commit artbox
95
96
97
98
              
              return $dataProvider;
          }
      }