Blame view

common/models/SeoLang.php 3.4 KB
d55d2fe0   Yarik   Multilanguage
1
  <?php
d55d2fe0   Yarik   Multilanguage
2
      
5c2eb7c8   Yarik   Big commit almost...
3
4
5
6
7
      namespace common\models;
      
      use common\modules\language\models\Language;
      use Yii;
      use yii\db\ActiveRecord;
d55d2fe0   Yarik   Multilanguage
8
9
      
      /**
5c2eb7c8   Yarik   Big commit almost...
10
       * This is the model class for table "seo_lang".
4428da8c   Yarik   Almost all databa...
11
       *
5c2eb7c8   Yarik   Big commit almost...
12
13
14
       * @property integer  $seo_id
       * @property integer  $language_id
       * @property string   $title
8af13427   Yarik   For leha commit.
15
       * @property string   $meta_description
5c2eb7c8   Yarik   Big commit almost...
16
17
18
19
20
       * @property string   $h1
       * @property string   $meta
       * @property string   $seo_text
       * @property Language $language
       * @property Seo      $seo
d55d2fe0   Yarik   Multilanguage
21
       */
5c2eb7c8   Yarik   Big commit almost...
22
      class SeoLang extends ActiveRecord
d55d2fe0   Yarik   Multilanguage
23
      {
5c2eb7c8   Yarik   Big commit almost...
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
          
          public static function primaryKey()
          {
              return [
                  'seo_id',
                  'language_id',
              ];
          }
          
          /**
           * @inheritdoc
           */
          public static function tableName()
          {
              return 'seo_lang';
          }
          
          /**
           * @inheritdoc
           */
          public function rules()
          {
              return [
                  [
                      [
8af13427   Yarik   For leha commit.
49
                          'meta_description',
5c2eb7c8   Yarik   Big commit almost...
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
                          'seo_text',
                      ],
                      'string',
                  ],
                  [
                      [
                          'title',
                          'h1',
                          'meta',
                      ],
                      'string',
                      'max' => 255,
                  ],
                  [
                      [
                          'seo_id',
                          'language_id',
                      ],
                      'unique',
                      'targetAttribute' => [
                          'seo_id',
                          'language_id',
                      ],
                      'message'         => 'The combination of Seo ID and Language ID has already been taken.',
                  ],
                  [
                      [ 'language_id' ],
                      'exist',
                      'skipOnError'     => true,
                      'targetClass'     => Language::className(),
8af13427   Yarik   For leha commit.
80
                      'targetAttribute' => [ 'language_id' => 'id' ],
5c2eb7c8   Yarik   Big commit almost...
81
82
83
84
85
86
                  ],
                  [
                      [ 'seo_id' ],
                      'exist',
                      'skipOnError'     => true,
                      'targetClass'     => Seo::className(),
4428da8c   Yarik   Almost all databa...
87
                      'targetAttribute' => [ 'seo_id' => 'id' ],
5c2eb7c8   Yarik   Big commit almost...
88
89
90
91
92
93
94
95
96
97
                  ],
              ];
          }
          
          /**
           * @inheritdoc
           */
          public function attributeLabels()
          {
              return [
4428da8c   Yarik   Almost all databa...
98
99
100
                  'seo_id'           => Yii::t('app', 'seo_id'),
                  'language_id'      => Yii::t('app', 'language_id'),
                  'title'            => Yii::t('app', 'title'),
8af13427   Yarik   For leha commit.
101
                  'meta_description' => Yii::t('app', 'meta_description'),
4428da8c   Yarik   Almost all databa...
102
103
104
                  'h1'               => Yii::t('app', 'h1'),
                  'meta'             => Yii::t('app', 'meta'),
                  'seo_text'         => Yii::t('app', 'seo_text'),
5c2eb7c8   Yarik   Big commit almost...
105
106
107
108
109
110
111
112
              ];
          }
          
          /**
           * @return \yii\db\ActiveQuery
           */
          public function getLanguage()
          {
8af13427   Yarik   For leha commit.
113
              return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]);
5c2eb7c8   Yarik   Big commit almost...
114
115
116
117
118
119
120
          }
          
          /**
           * @return \yii\db\ActiveQuery
           */
          public function getSeo()
          {
4428da8c   Yarik   Almost all databa...
121
              return $this->hasOne(Seo::className(), [ 'id' => 'seo_id' ]);
5c2eb7c8   Yarik   Big commit almost...
122
          }
d55d2fe0   Yarik   Multilanguage
123
      }