Blame view

common/models/Slider.php 2.63 KB
d8c1a2e0   Yarik   Big commit artbox
1
  <?php
5c2eb7c8   Yarik   Big commit almost...
2
3
4
5
6
7
      
      namespace common\models;
      
      use Yii;
      use yii\db\ActiveRecord;
      
d8c1a2e0   Yarik   Big commit artbox
8
      /**
5c2eb7c8   Yarik   Big commit almost...
9
       * This is the model class for table "slider".
4428da8c   Yarik   Almost all databa...
10
11
12
13
14
15
16
17
       *
       * @property integer       $id
       * @property integer       $speed
       * @property integer       $duration
       * @property string        $title
       * @property integer       $status
       * @property integer       $width
       * @property integer       $height
c70f24ea   Yarik   For Leha commit.
18
       * @property SliderImage[] $sliderImages
d8c1a2e0   Yarik   Big commit artbox
19
       */
5c2eb7c8   Yarik   Big commit almost...
20
      class Slider extends ActiveRecord
d8c1a2e0   Yarik   Big commit artbox
21
      {
5c2eb7c8   Yarik   Big commit almost...
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
56
57
58
59
60
61
62
63
          
          /**
           * @inheritdoc
           */
          public static function tableName()
          {
              return 'slider';
          }
          
          /**
           * @inheritdoc
           */
          public function rules()
          {
              return [
                  [
                      [
                          'speed',
                          'duration',
                          'status',
                          'width',
                          'height',
                      ],
                      'integer',
                  ],
                  [
                      [ 'title' ],
                      'string',
                      'max' => 200,
                  ],
                  [
                      [
                          'width',
                          'height',
                          'title',
                      ],
                      'required',
                  ],
                  [
                      'title',
                      'unique',
                      'targetClass' => '\common\models\Slider',
4428da8c   Yarik   Almost all databa...
64
65
66
67
68
69
70
                      'message'     => Yii::t(
                          'app',
                          'message',
                          [
                              'field' => 'Title',
                          ]
                      ),
5c2eb7c8   Yarik   Big commit almost...
71
72
73
74
75
76
77
78
79
80
                  ],
              ];
          }
          
          /**
           * @inheritdoc
           */
          public function attributeLabels()
          {
              return [
4428da8c   Yarik   Almost all databa...
81
82
83
84
85
86
87
                  'id'       => Yii::t('app', 'slider_id'),
                  'speed'    => Yii::t('app', 'speed'),
                  'duration' => Yii::t('app', 'duration'),
                  'title'    => Yii::t('app', 'title'),
                  'status'   => Yii::t('app', 'status'),
                  'width'    => Yii::t('app', 'width'),
                  'height'   => Yii::t('app', 'height'),
5c2eb7c8   Yarik   Big commit almost...
88
89
90
91
92
93
              ];
          }
          
          /**
           * @return \yii\db\ActiveQuery
           */
c70f24ea   Yarik   For Leha commit.
94
          public function getSliderImages()
5c2eb7c8   Yarik   Big commit almost...
95
          {
4428da8c   Yarik   Almost all databa...
96
              return $this->hasMany(SliderImage::className(), [ 'slider_id' => 'id' ])
5c2eb7c8   Yarik   Big commit almost...
97
98
99
                          ->where([ SliderImage::tableName() . '.status' => 1 ]);
          }
          
d8c1a2e0   Yarik   Big commit artbox
100
      }