Blame view

common/models/Gallery.php 2.83 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
f0a961be   Yarik   test
20
21
       * @method string minImg(string $dir, $width, $height = NULL) Resizes image
       * @method array ShowGallery(string $array) Splits string to image paths array
7eb29439   Yarik   test
22
       */
588209fc   Yarik   test
23
      class Gallery extends \yii\db\ActiveRecord
7eb29439   Yarik   test
24
      {
7eb29439   Yarik   test
25
  
588209fc   Yarik   test
26
27
28
29
30
31
32
          /**
           * @inheritdoc
           */
          public static function tableName()
          {
              return 'gallery';
          }
ea09d15d   Yarik   test
33
  
588209fc   Yarik   test
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
          /**
           * @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
51
52
53
                  [
                      'class'              => 'common\behaviors\ShowImage',
                  ],
588209fc   Yarik   test
54
55
              ];
          }
7eb29439   Yarik   test
56
  
588209fc   Yarik   test
57
58
59
60
61
62
63
          /**
           * @inheritdoc
           */
          public function rules()
          {
              return [
                  [
4a3f5562   Yarik   test
64
                      [ 'name', 'cover' ],
588209fc   Yarik   test
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
90
91
                      'required',
                  ],
                  [
                      [ 'type' ],
                      'integer',
                  ],
                  [
                      [ 'photo' ],
                      'string',
                  ],
                  [
                      [
                          'name',
                          'cover',
                      ],
                      'string',
                      'max' => 255,
                  ],
              ];
          }
  
          /**
           * @inheritdoc
           */
          public function attributeLabels()
          {
              return [
06ec2844   Administrator   28.03.16
92
93
94
95
96
97
98
99
                  '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
100
101
              ];
          }
7eb29439   Yarik   test
102
      }