Blame view

common/models/EventLang.php 4.01 KB
d55d2fe0   Yarik   Multilanguage
1
  <?php
d55d2fe0   Yarik   Multilanguage
2
      
93c267f7   Yarik   Multilanguage big...
3
      namespace common\models;
d55d2fe0   Yarik   Multilanguage
4
      
93c267f7   Yarik   Multilanguage big...
5
6
      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 "event_lang".
c70f24ea   Yarik   For Leha commit.
11
       *
93c267f7   Yarik   Multilanguage big...
12
13
       * @property integer  $event_id
       * @property integer  $language_id
8af13427   Yarik   For leha commit.
14
       * @property string   $title
93c267f7   Yarik   Multilanguage big...
15
16
       * @property string   $body
       * @property string   $meta_title
8af13427   Yarik   For leha commit.
17
       * @property string   $meta_description
93c267f7   Yarik   Multilanguage big...
18
19
20
21
22
       * @property string   $seo_text
       * @property string   $h1
       * @property string   $alias
       * @property Event    $event
       * @property Language $language
d55d2fe0   Yarik   Multilanguage
23
       */
5c2eb7c8   Yarik   Big commit almost...
24
      class EventLang extends ActiveRecord
d55d2fe0   Yarik   Multilanguage
25
      {
93c267f7   Yarik   Multilanguage big...
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
          
          public static function primaryKey()
          {
              return [
                  'event_id',
                  'language_id',
              ];
          }
          
          /**
           * @inheritdoc
           */
          public static function tableName()
          {
              return 'event_lang';
          }
          
          public function behaviors()
          {
              return [
                  'slug' => [
c70f24ea   Yarik   For Leha commit.
47
                      'class' => 'common\behaviors\Slug',
93c267f7   Yarik   Multilanguage big...
48
49
50
51
52
53
54
55
56
57
58
59
                  ],
              ];
          }
          
          /**
           * @inheritdoc
           */
          public function rules()
          {
              return [
                  [
                      [
8af13427   Yarik   For leha commit.
60
                          'title',
93c267f7   Yarik   Multilanguage big...
61
62
63
64
65
66
67
68
69
70
71
72
73
                          'body',
                      ],
                      'required',
                  ],
                  [
                      [
                          'body',
                          'seo_text',
                      ],
                      'string',
                  ],
                  [
                      [
8af13427   Yarik   For leha commit.
74
                          'title',
93c267f7   Yarik   Multilanguage big...
75
                          'meta_title',
8af13427   Yarik   For leha commit.
76
                          'meta_description',
93c267f7   Yarik   Multilanguage big...
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
                          'h1',
                          'alias',
                      ],
                      'string',
                      'max' => 255,
                  ],
                  [
                      [
                          'event_id',
                          'language_id',
                      ],
                      'unique',
                      'targetAttribute' => [
                          'event_id',
                          'language_id',
                      ],
                      'message'         => 'The combination of Event ID and Language ID has already been taken.',
                  ],
                  [
                      [ 'event_id' ],
                      'exist',
                      'skipOnError'     => true,
                      'targetClass'     => Event::className(),
8af13427   Yarik   For leha commit.
100
                      'targetAttribute' => [ 'event_id' => 'id' ],
93c267f7   Yarik   Multilanguage big...
101
102
103
104
105
106
                  ],
                  [
                      [ 'language_id' ],
                      'exist',
                      'skipOnError'     => true,
                      'targetClass'     => Language::className(),
8af13427   Yarik   For leha commit.
107
                      'targetAttribute' => [ 'language_id' => 'id' ],
93c267f7   Yarik   Multilanguage big...
108
109
110
111
112
113
114
115
116
117
                  ],
              ];
          }
          
          /**
           * @inheritdoc
           */
          public function attributeLabels()
          {
              return [
c70f24ea   Yarik   For Leha commit.
118
119
120
121
122
                  'event_id'         => Yii::t('app', 'event_id'),
                  'language_id'      => Yii::t('app', 'language_id'),
                  'title'            => Yii::t('app', 'name'),
                  'body'             => Yii::t('app', 'body'),
                  'meta_title'       => Yii::t('app', 'meta_title'),
8af13427   Yarik   For leha commit.
123
                  'meta_description' => Yii::t('app', 'meta_description'),
c70f24ea   Yarik   For Leha commit.
124
125
                  'seo_text'         => Yii::t('app', 'seo_text'),
                  'h1'               => Yii::t('app', 'h1'),
93c267f7   Yarik   Multilanguage big...
126
127
128
129
130
131
132
133
              ];
          }
          
          /**
           * @return \yii\db\ActiveQuery
           */
          public function getEvent()
          {
8af13427   Yarik   For leha commit.
134
              return $this->hasOne(Event::className(), [ 'id' => 'event_id' ]);
93c267f7   Yarik   Multilanguage big...
135
136
137
138
139
140
141
          }
          
          /**
           * @return \yii\db\ActiveQuery
           */
          public function getLanguage()
          {
8af13427   Yarik   For leha commit.
142
              return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]);
93c267f7   Yarik   Multilanguage big...
143
          }
d55d2fe0   Yarik   Multilanguage
144
      }