Blame view

common/modules/rubrication/models/TaxGroupLang.php 3.48 KB
d55d2fe0   Yarik   Multilanguage
1
  <?php
d55d2fe0   Yarik   Multilanguage
2
      
93c267f7   Yarik   Multilanguage big...
3
4
5
6
      namespace common\modules\rubrication\models;
      
      use common\modules\language\models\Language;
      use Yii;
5c2eb7c8   Yarik   Big commit almost...
7
      use yii\db\ActiveRecord;
d55d2fe0   Yarik   Multilanguage
8
9
      
      /**
93c267f7   Yarik   Multilanguage big...
10
       * This is the model class for table "tax_group_lang".
c70f24ea   Yarik   For Leha commit.
11
       *
93c267f7   Yarik   Multilanguage big...
12
13
       * @property integer  $tax_group_id
       * @property integer  $language_id
8af13427   Yarik   For leha commit.
14
       * @property string   $title
93c267f7   Yarik   Multilanguage big...
15
16
17
18
       * @property string   $alias
       * @property string   $description
       * @property Language $language
       * @property TaxGroup $taxGroup
d55d2fe0   Yarik   Multilanguage
19
       */
5c2eb7c8   Yarik   Big commit almost...
20
      class TaxGroupLang extends ActiveRecord
d55d2fe0   Yarik   Multilanguage
21
      {
93c267f7   Yarik   Multilanguage big...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
          
          public static function primaryKey()
          {
              return [
                  'tax_group_id',
                  'language_id',
              ];
          }
          
          /**
           * @inheritdoc
           */
          public static function tableName()
          {
              return 'tax_group_lang';
          }
          
          public function behaviors()
          {
              return [
                  'slug' => [
c70f24ea   Yarik   For Leha commit.
43
                      'class' => 'common\behaviors\Slug',
93c267f7   Yarik   Multilanguage big...
44
45
46
47
48
49
50
51
52
53
54
                  ],
              ];
          }
          
          /**
           * @inheritdoc
           */
          public function rules()
          {
              return [
                  [
8af13427   Yarik   For leha commit.
55
                      [ 'title' ],
93c267f7   Yarik   Multilanguage big...
56
57
58
59
60
61
62
63
                      'required',
                  ],
                  [
                      [ 'description' ],
                      'string',
                  ],
                  [
                      [
8af13427   Yarik   For leha commit.
64
                          'title',
93c267f7   Yarik   Multilanguage big...
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
                          'alias',
                      ],
                      'string',
                      'max' => 255,
                  ],
                  [
                      [
                          'tax_group_id',
                          'language_id',
                      ],
                      'unique',
                      'targetAttribute' => [
                          'tax_group_id',
                          'language_id',
                      ],
                      'message'         => 'The combination of Tax Group ID and Language ID has already been taken.',
                  ],
                  [
                      [ 'language_id' ],
                      'exist',
                      'skipOnError'     => true,
                      'targetClass'     => Language::className(),
8af13427   Yarik   For leha commit.
87
                      'targetAttribute' => [ 'language_id' => 'id' ],
93c267f7   Yarik   Multilanguage big...
88
89
90
91
92
93
                  ],
                  [
                      [ 'tax_group_id' ],
                      'exist',
                      'skipOnError'     => true,
                      'targetClass'     => TaxGroup::className(),
c70f24ea   Yarik   For Leha commit.
94
                      'targetAttribute' => [ 'tax_group_id' => 'id' ],
93c267f7   Yarik   Multilanguage big...
95
96
97
98
99
100
101
102
103
104
105
106
                  ],
              ];
          }
          
          /**
           * @inheritdoc
           */
          public function attributeLabels()
          {
              return [
                  'tax_group_id' => Yii::t('app', 'Tax Group ID'),
                  'language_id'  => Yii::t('app', 'Language ID'),
c70f24ea   Yarik   For Leha commit.
107
                  'title'        => Yii::t('app', 'Name'),
93c267f7   Yarik   Multilanguage big...
108
109
110
111
112
113
114
115
116
117
                  'description'  => Yii::t('app', 'Description'),
                  'alias'        => Yii::t('app', 'Alias'),
              ];
          }
          
          /**
           * @return \yii\db\ActiveQuery
           */
          public function getLanguage()
          {
8af13427   Yarik   For leha commit.
118
              return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]);
93c267f7   Yarik   Multilanguage big...
119
120
121
122
123
124
125
          }
          
          /**
           * @return \yii\db\ActiveQuery
           */
          public function getTaxGroup()
          {
c70f24ea   Yarik   For Leha commit.
126
              return $this->hasOne(TaxGroup::className(), [ 'id' => 'tax_group_id' ]);
93c267f7   Yarik   Multilanguage big...
127
          }
d55d2fe0   Yarik   Multilanguage
128
      }