Blame view

common/models/SliderImageSearch.php 2.62 KB
d8c1a2e0   Yarik   Big commit artbox
1
  <?php

d55d2fe0   Yarik   Multilanguage
2
3
4
5
6
7
      

      namespace common\models;

      

      use yii\base\Model;

      use yii\data\ActiveDataProvider;

      

d8c1a2e0   Yarik   Big commit artbox
8
      /**

d55d2fe0   Yarik   Multilanguage
9
10
       * SliderImageSearch represents the model behind the search form about

       * `common\models\SliderImage`.

d8c1a2e0   Yarik   Big commit artbox
11
       */

d55d2fe0   Yarik   Multilanguage
12
      class SliderImageSearch extends SliderImage

d8c1a2e0   Yarik   Big commit artbox
13
      {

d55d2fe0   Yarik   Multilanguage
14
15
16
17
18
19
20
21
22
23
24
25
26
27
          

          public function behaviors()

          {

              return [];

          }

          

          /**

           * @inheritdoc

           */

          public function rules()

          {

              return [

                  [

                      [

4428da8c   Yarik   Almost all databa...
28
                          'id',

d55d2fe0   Yarik   Multilanguage
29
30
31
32
33
34
35
36
                          'slider_id',

                          'status',

                          'sort',

                      ],

                      'integer',

                  ],

                  [

                      [

d55d2fe0   Yarik   Multilanguage
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
                          'url',

                      ],

                      'safe',

                  ],

              ];

          }

          

          /**

           * @inheritdoc

           */

          public function scenarios()

          {

              // bypass scenarios() implementation in the parent class

              return Model::scenarios();

          }

          

          /**

           * Creates data provider instance with search query applied

           *

           * @param array $params

           * @param       $slider_id Slider id

           *

           * @return ActiveDataProvider

           */

          public function search($slider_id, $params)

          {

              $query = SliderImage::find();

              

              // add conditions that should always apply here

              

4428da8c   Yarik   Almost all databa...
67
68
69
70
71
              $dataProvider = new ActiveDataProvider(

                  [

                      'query' => $query,

                  ]

              );

d55d2fe0   Yarik   Multilanguage
72
73
74
              

              $this->load($params);

              

4428da8c   Yarik   Almost all databa...
75
              if (!$this->validate()) {

d55d2fe0   Yarik   Multilanguage
76
77
78
79
80
81
                  // 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

4428da8c   Yarik   Almost all databa...
82
83
84
85
86
87
88
89
              $query->andFilterWhere(

                  [

                      'id'        => $this->id,

                      'slider_id' => $slider_id,

                      'status'    => $this->status,

                      'sort'      => $this->sort,

                  ]

              );

d55d2fe0   Yarik   Multilanguage
90
              

4428da8c   Yarik   Almost all databa...
91
92
93
94
95
96
97
              $query->andFilterWhere(

                  [

                      'like',

                      'url',

                      $this->url,

                  ]

              );

d55d2fe0   Yarik   Multilanguage
98
              

d8c1a2e0   Yarik   Big commit artbox
99
100
              return $dataProvider;

          }

d8c1a2e0   Yarik   Big commit artbox
101
      }