Blame view

common/models/Gallery.php 2.66 KB
7eb29439   Yarik   test
1
2
  <?php
  
588209fc   Yarik   test
3
      namespace common\models;
7eb29439   Yarik   test
4
  
588209fc   Yarik   test
5
6
7
8
      use Yii;
      use yii\behaviors\BlameableBehavior;
      use yii\behaviors\TimestampBehavior;
      use yii\db\Expression;
7eb29439   Yarik   test
9
  
7eb29439   Yarik   test
10
      /**
588209fc   Yarik   test
11
12
13
14
15
16
17
18
19
       * This is the model class for table "gallery".
       * @property integer $gallery_id
       * @property integer $user_id
       * @property string  $name
       * @property string  $date_add
       * @property integer $user_add_id
       * @property string  $cover
       * @property integer $type
       * @property string  $photo
7eb29439   Yarik   test
20
       */
588209fc   Yarik   test
21
      class Gallery extends \yii\db\ActiveRecord
7eb29439   Yarik   test
22
      {
7eb29439   Yarik   test
23
  
588209fc   Yarik   test
24
25
26
27
28
29
30
          /**
           * @inheritdoc
           */
          public static function tableName()
          {
              return 'gallery';
          }
ea09d15d   Yarik   test
31
  
588209fc   Yarik   test
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
          /**
           * @inheritdoc
           */
          public function behaviors()
          {
              return [
                  [
                      'class'              => BlameableBehavior::className(),
                      'createdByAttribute' => 'user_id',
                      'updatedByAttribute' => false,
                  ],
                  [
                      'class'              => TimestampBehavior::className(),
                      'createdAtAttribute' => 'date_add',
                      'updatedAtAttribute' => false,
                      'value'              => new Expression('NOW()'),
                  ],
9217ef8e   Administrator   09.02.16
49
50
51
                  [
                      'class'              => 'common\behaviors\ShowImage',
                  ],
588209fc   Yarik   test
52
53
              ];
          }
7eb29439   Yarik   test
54
  
588209fc   Yarik   test
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
          /**
           * @inheritdoc
           */
          public function rules()
          {
              return [
                  [
                      [ 'name' ],
                      'required',
                  ],
                  [
                      [ 'type' ],
                      'integer',
                  ],
                  [
                      [ 'photo' ],
                      'string',
                  ],
                  [
                      [
                          'name',
                          'cover',
                      ],
                      'string',
                      'max' => 255,
                  ],
              ];
          }
  
          /**
           * @inheritdoc
           */
          public function attributeLabels()
          {
              return [
06ec2844   Administrator   28.03.16
90
91
92
93
94
95
96
97
                  'gallery_id'  => Yii::t('app', 'gallery_id'),
                  'user_id'     => Yii::t('app', 'user_id'),
                  'name'        => Yii::t('app', 'name'),
                  'date_add'    => Yii::t('app', 'date_add'),
                  'user_add_id' => Yii::t('app', 'user_add_id'),
                  'cover'       => Yii::t('app', 'cover_g'),
                  'type'        => Yii::t('app', 'type_g'),
                  'photo'       => Yii::t('app', 'photo_g'),
588209fc   Yarik   test
98
99
              ];
          }
7eb29439   Yarik   test
100
      }