Blame view

models/ShopLang.php 4.26 KB
a61ab7a7   Anastasia   stock
1
  <?php
77d77c34   Anastasia   stock
2
3
4
5
6
7
8
9
      
      namespace artbox\stock\models;
      
      use artbox\core\behaviors\SlugBehavior;
      use artbox\core\models\Alias;
      use artbox\core\models\Language;
      use yii\db\ActiveRecord;
      
a61ab7a7   Anastasia   stock
10
      /**
77d77c34   Anastasia   stock
11
12
13
14
15
16
17
18
19
20
       * This is the model class for table "shop_lang".
       *
       * @property integer  $shop_id
       * @property integer  $language_id
       * @property string   $title
       * @property integer  $alias_id
       * @property string   $description
       * @property Alias    $alias
       * @property Language $language
       * @property Shop     $shop
a61ab7a7   Anastasia   stock
21
       */
77d77c34   Anastasia   stock
22
      class ShopLang extends ActiveRecord
a61ab7a7   Anastasia   stock
23
      {
77d77c34   Anastasia   stock
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
          /**
           * @inheritdoc
           */
          public static function tableName()
          {
              return 'shop_lang';
          }
          
          /**
           * @inheritdoc
           */
          public function behaviors()
          {
              return [
                  'slug' => [
                      'class'  => SlugBehavior::className(),
                      'action' => 'shop/view',
                      'params' => [
                          'id' => 'shop_id',
                      ],
                      'fields' => [
                          'title'       => \Yii::t('stock', 'Title'),
                          'description' => \Yii::t('stock', 'Description'),
                          'address'     => \Yii::t('stock', 'Address'),
                      ],
a61ab7a7   Anastasia   stock
49
                  ],
77d77c34   Anastasia   stock
50
51
52
53
54
55
56
57
58
59
60
61
              ];
          }
          public function rules()
          {
              return [
                  [
                      [
                          'shop_id',
                          'language_id',
                          'title',
                      ],
                      'required',
a61ab7a7   Anastasia   stock
62
                  ],
77d77c34   Anastasia   stock
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
                  [
                      [
                          'shop_id',
                          'language_id',
                          'alias_id',
                      ],
                      'integer',
                  ],
                  [
                      [ 'description' ],
                      'string',
                  ],
                  [
                      [ 'title' ],
                      'string',
                      'max' => 255,
                  ],
                  [
                      [ 'address' ],
                      'string',
                      'max' => 255,
                  ],
                  [
                      [ 'alias_id' ],
                      'unique',
                  ],
                  [
                      [ 'alias_id' ],
                      'exist',
                      'skipOnError'     => true,
                      'targetClass'     => Alias::className(),
                      'targetAttribute' => [ 'alias_id' => 'id' ],
                  ],
                  [
                      [ 'language_id' ],
                      'exist',
                      'skipOnError'     => true,
                      'targetClass'     => Language::className(),
                      'targetAttribute' => [ 'language_id' => 'id' ],
                  ],
                  [
                      [ 'shop_id' ],
                      'exist',
                      'skipOnError'     => true,
                      'targetClass'     => Shop::className(),
                      'targetAttribute' => [ 'shop_id' => 'id' ],
                  ],
              ];
          }
          
          /**
           * @inheritdoc
           */
          public function attributeLabels()
          {
              return [
                  'shop_id'     => 'Shop ID',
                  'language_id' => 'Language ID',
                  'title'       => \Yii::t('stock', 'Title'),
                  'alias_id'    => 'Alias ID',
                  'description' => \Yii::t('stock', 'Description'),
                  'address'     => \Yii::t('stock', 'Address'),
              ];
          }
          
          /**
           * @return \yii\db\ActiveQuery
           */
          public function getAlias()
          {
              return $this->hasOne(Alias::className(), [ 'id' => 'alias_id' ]);
          }
          
          /**
           * @return \yii\db\ActiveQuery
           */
          public function getLanguage()
          {
              return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]);
          }
          
          /**
           * @return \yii\db\ActiveQuery
           */
          public function getShop()
          {
              return $this->hasOne(Shop::className(), [ 'id' => 'shop_id' ]);
          }
a61ab7a7   Anastasia   stock
151
      }