| @@ 26-133 (lines=108) @@ | ||
| 23 | * |
|
| 24 | * @package app\models |
|
| 25 | */ |
|
| 26 | class CategoryLanguage extends ActiveRecord |
|
| 27 | { |
|
| 28 | /** |
|
| 29 | * @inheritdoc |
|
| 30 | */ |
|
| 31 | public static function tableName() |
|
| 32 | { |
|
| 33 | return 'categories_language'; |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @inheritdoc |
|
| 38 | */ |
|
| 39 | public function rules() |
|
| 40 | { |
|
| 41 | return [ |
|
| 42 | [ |
|
| 43 | [ |
|
| 44 | 'categories_id', |
|
| 45 | 'language_id', |
|
| 46 | ], |
|
| 47 | 'required', |
|
| 48 | ], |
|
| 49 | [ |
|
| 50 | [ |
|
| 51 | 'categories_id', |
|
| 52 | 'language_id', |
|
| 53 | ], |
|
| 54 | 'integer', |
|
| 55 | ], |
|
| 56 | [ |
|
| 57 | [ |
|
| 58 | 'description', |
|
| 59 | 'content', |
|
| 60 | ], |
|
| 61 | 'string', |
|
| 62 | ], |
|
| 63 | [ |
|
| 64 | [ |
|
| 65 | 'created_at', |
|
| 66 | 'updated_at', |
|
| 67 | ], |
|
| 68 | 'safe', |
|
| 69 | ], |
|
| 70 | [ |
|
| 71 | [ |
|
| 72 | 'title', |
|
| 73 | 'metaKeys', |
|
| 74 | 'metaDescription', |
|
| 75 | ], |
|
| 76 | 'string', |
|
| 77 | 'max' => 255, |
|
| 78 | ], |
|
| 79 | [ |
|
| 80 | ['categories_id'], |
|
| 81 | 'exist', |
|
| 82 | 'skipOnError' => true, |
|
| 83 | 'targetClass' => Category::class, |
|
| 84 | 'targetAttribute' => ['categories_id' => 'id'], |
|
| 85 | ], |
|
| 86 | [ |
|
| 87 | ['language_id'], |
|
| 88 | 'exist', |
|
| 89 | 'skipOnError' => true, |
|
| 90 | 'targetClass' => Language::class, |
|
| 91 | 'targetAttribute' => ['language_id' => 'id'], |
|
| 92 | ], |
|
| 93 | ]; |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * @inheritdoc |
|
| 98 | */ |
|
| 99 | public function attributeLabels() |
|
| 100 | { |
|
| 101 | return [ |
|
| 102 | 'categories_id' => 'Category ID', |
|
| 103 | 'language_id' => 'Language ID', |
|
| 104 | 'title' => Yii::t('app', 'Title'), |
|
| 105 | 'description' => Yii::t('app', 'Description'), |
|
| 106 | 'content' => Yii::t('app', 'Content'), |
|
| 107 | 'metaKeys' => Yii::t('app', 'Meta keys'), |
|
| 108 | 'metaDescription' => Yii::t('app', 'Meta description'), |
|
| 109 | 'created_at' => Yii::t('app', 'Created date'), |
|
| 110 | 'updated_at' => Yii::t('app', 'Updated date'), |
|
| 111 | ]; |
|
| 112 | } |
|
| 113 | ||
| 114 | /** |
|
| 115 | * @return \yii\db\ActiveQuery |
|
| 116 | */ |
|
| 117 | public function getCategory() |
|
| 118 | { |
|
| 119 | return $this->hasOne(Category::class, [ |
|
| 120 | 'id' => 'categories_id' |
|
| 121 | ]); |
|
| 122 | } |
|
| 123 | ||
| 124 | /** |
|
| 125 | * @return \yii\db\ActiveQuery |
|
| 126 | */ |
|
| 127 | public function getLanguage() |
|
| 128 | { |
|
| 129 | return $this->hasOne(Language::class, [ |
|
| 130 | 'id' => 'language_id' |
|
| 131 | ]); |
|
| 132 | } |
|
| 133 | } |
|
| 134 | ||
| @@ 26-133 (lines=108) @@ | ||
| 23 | * |
|
| 24 | * @package app\models |
|
| 25 | */ |
|
| 26 | class PageLanguage extends ActiveRecord |
|
| 27 | { |
|
| 28 | /** |
|
| 29 | * @inheritdoc |
|
| 30 | */ |
|
| 31 | public static function tableName() |
|
| 32 | { |
|
| 33 | return 'pages_language'; |
|
| 34 | } |
|
| 35 | ||
| 36 | /** |
|
| 37 | * @inheritdoc |
|
| 38 | */ |
|
| 39 | public function rules() |
|
| 40 | { |
|
| 41 | return [ |
|
| 42 | [ |
|
| 43 | [ |
|
| 44 | 'pages_id', |
|
| 45 | 'language_id', |
|
| 46 | ], |
|
| 47 | 'required', |
|
| 48 | ], |
|
| 49 | [ |
|
| 50 | [ |
|
| 51 | 'pages_id', |
|
| 52 | 'language_id', |
|
| 53 | ], |
|
| 54 | 'integer', |
|
| 55 | ], |
|
| 56 | [ |
|
| 57 | [ |
|
| 58 | 'description', |
|
| 59 | 'content', |
|
| 60 | ], |
|
| 61 | 'string', |
|
| 62 | ], |
|
| 63 | [ |
|
| 64 | [ |
|
| 65 | 'created_at', |
|
| 66 | 'updated_at', |
|
| 67 | ], |
|
| 68 | 'safe', |
|
| 69 | ], |
|
| 70 | [ |
|
| 71 | [ |
|
| 72 | 'title', |
|
| 73 | 'metaKeys', |
|
| 74 | 'metaDescription', |
|
| 75 | ], |
|
| 76 | 'string', |
|
| 77 | 'max' => 255, |
|
| 78 | ], |
|
| 79 | [ |
|
| 80 | ['pages_id'], |
|
| 81 | 'exist', |
|
| 82 | 'skipOnError' => true, |
|
| 83 | 'targetClass' => Page::class, |
|
| 84 | 'targetAttribute' => ['pages_id' => 'id'], |
|
| 85 | ], |
|
| 86 | [ |
|
| 87 | ['language_id'], |
|
| 88 | 'exist', |
|
| 89 | 'skipOnError' => true, |
|
| 90 | 'targetClass' => Language::class, |
|
| 91 | 'targetAttribute' => ['language_id' => 'id'], |
|
| 92 | ], |
|
| 93 | ]; |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * @inheritdoc |
|
| 98 | */ |
|
| 99 | public function attributeLabels() |
|
| 100 | { |
|
| 101 | return [ |
|
| 102 | 'pages_id' => 'Page ID', |
|
| 103 | 'language_id' => 'Language ID', |
|
| 104 | 'title' => Yii::t('app', 'Title'), |
|
| 105 | 'description' => Yii::t('app', 'Description'), |
|
| 106 | 'content' => Yii::t('app', 'Content'), |
|
| 107 | 'metaKeys' => Yii::t('app', 'Meta keys'), |
|
| 108 | 'metaDescription' => Yii::t('app', 'Meta description'), |
|
| 109 | 'created_at' => Yii::t('app', 'Created date'), |
|
| 110 | 'updated_at' => Yii::t('app', 'Updated date'), |
|
| 111 | ]; |
|
| 112 | } |
|
| 113 | ||
| 114 | /** |
|
| 115 | * @return \yii\db\ActiveQuery |
|
| 116 | */ |
|
| 117 | public function getPage() |
|
| 118 | { |
|
| 119 | return $this->hasOne(Page::class, [ |
|
| 120 | 'id' => 'pages_id' |
|
| 121 | ]); |
|
| 122 | } |
|
| 123 | ||
| 124 | /** |
|
| 125 | * @return \yii\db\ActiveQuery |
|
| 126 | */ |
|
| 127 | public function getLanguage() |
|
| 128 | { |
|
| 129 | return $this->hasOne(Language::class, [ |
|
| 130 | 'id' => 'language_id' |
|
| 131 | ]); |
|
| 132 | } |
|
| 133 | } |
|
| 134 | ||