Blame view

common/models/EventLang.php 3.98 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
11
12
       * This is the model class for table "event_lang".
       * @property integer  $event_id
       * @property integer  $language_id
8af13427   Yarik   For leha commit.
13
       * @property string   $title
93c267f7   Yarik   Multilanguage big...
14
15
       * @property string   $body
       * @property string   $meta_title
8af13427   Yarik   For leha commit.
16
       * @property string   $meta_description
93c267f7   Yarik   Multilanguage big...
17
18
19
20
21
       * @property string   $seo_text
       * @property string   $h1
       * @property string   $alias
       * @property Event    $event
       * @property Language $language
d55d2fe0   Yarik   Multilanguage
22
       */
5c2eb7c8   Yarik   Big commit almost...
23
      class EventLang extends ActiveRecord
d55d2fe0   Yarik   Multilanguage
24
      {
93c267f7   Yarik   Multilanguage big...
25
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' => [
                      'class'         => 'common\behaviors\Slug',
93c267f7   Yarik   Multilanguage big...
47
48
49
50
51
52
53
54
55
56
57
58
                  ],
              ];
          }
          
          /**
           * @inheritdoc
           */
          public function rules()
          {
              return [
                  [
                      [
8af13427   Yarik   For leha commit.
59
                          'title',
93c267f7   Yarik   Multilanguage big...
60
61
62
63
64
65
66
67
68
69
70
71
72
                          'body',
                      ],
                      'required',
                  ],
                  [
                      [
                          'body',
                          'seo_text',
                      ],
                      'string',
                  ],
                  [
                      [
8af13427   Yarik   For leha commit.
73
                          'title',
93c267f7   Yarik   Multilanguage big...
74
                          'meta_title',
8af13427   Yarik   For leha commit.
75
                          'meta_description',
93c267f7   Yarik   Multilanguage big...
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
                          '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.
99
                      'targetAttribute' => [ 'event_id' => 'id' ],
93c267f7   Yarik   Multilanguage big...
100
101
102
103
104
105
                  ],
                  [
                      [ 'language_id' ],
                      'exist',
                      'skipOnError'     => true,
                      'targetClass'     => Language::className(),
8af13427   Yarik   For leha commit.
106
                      'targetAttribute' => [ 'language_id' => 'id' ],
93c267f7   Yarik   Multilanguage big...
107
108
109
110
111
112
113
114
115
116
                  ],
              ];
          }
          
          /**
           * @inheritdoc
           */
          public function attributeLabels()
          {
              return [
b569ac34   Eugeny Galkovskiy   MESSAGES !!!! EVGEN!
117
118
                  'event_id'    => Yii::t('app', 'event_id'),
                  'language_id' => Yii::t('app', 'language_id'),
8af13427   Yarik   For leha commit.
119
                  'title'        => Yii::t('app', 'name'),
b569ac34   Eugeny Galkovskiy   MESSAGES !!!! EVGEN!
120
121
                  'body'        => Yii::t('app', 'body'),
                  'meta_title'  => Yii::t('app', 'meta_title'),
8af13427   Yarik   For leha commit.
122
                  'meta_description' => Yii::t('app', 'meta_description'),
b569ac34   Eugeny Galkovskiy   MESSAGES !!!! EVGEN!
123
124
                  'seo_text'    => Yii::t('app', 'seo_text'),
                  'h1'          => Yii::t('app', 'h1'),
93c267f7   Yarik   Multilanguage big...
125
126
127
128
129
130
131
132
              ];
          }
          
          /**
           * @return \yii\db\ActiveQuery
           */
          public function getEvent()
          {
8af13427   Yarik   For leha commit.
133
              return $this->hasOne(Event::className(), [ 'id' => 'event_id' ]);
93c267f7   Yarik   Multilanguage big...
134
135
136
137
138
139
140
          }
          
          /**
           * @return \yii\db\ActiveQuery
           */
          public function getLanguage()
          {
8af13427   Yarik   For leha commit.
141
              return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]);
93c267f7   Yarik   Multilanguage big...
142
          }
d55d2fe0   Yarik   Multilanguage
143
      }