LabelLang.php 2.72 KB
<?php
    
    namespace artbox\order\models;
    
    use artbox\core\models\Language;
    use Yii;
    
    /**
     * This is the model class for table "label_lang".
     *
     * @property integer  $label_id
     * @property integer  $language_id
     * @property string   $title
     * @property string   $description
     * @property Label    $label
     * @property Language $language
     */
    class LabelLang extends \yii\db\ActiveRecord
    {
        /**
         * @inheritdoc
         */
        public static function tableName()
        {
            return 'label_lang';
        }
        
        /**
         * @inheritdoc
         */
        public function rules()
        {
            return [
                [
                    [
                        'label_id',
                        'language_id',
                        'title',
                    ],
                    'required',
                ],
                [
                    [
                        'label_id',
                        'language_id',
                    ],
                    'integer',
                ],
                [
                    [ 'description' ],
                    'string',
                ],
                [
                    [ 'title' ],
                    'string',
                    'max' => 255,
                ],
                [
                    [ 'label_id' ],
                    'exist',
                    'skipOnError'     => true,
                    'targetClass'     => Label::className(),
                    'targetAttribute' => [ 'label_id' => 'id' ],
                ],
                [
                    [ 'language_id' ],
                    'exist',
                    'skipOnError'     => true,
                    'targetClass'     => Language::className(),
                    'targetAttribute' => [ 'language_id' => 'id' ],
                ],
            ];
        }
        
        /**
         * @inheritdoc
         */
        public function attributeLabels()
        {
            return [
                'label_id'    => Yii::t('order', 'Label ID'),
                'language_id' => Yii::t('order', 'Language ID'),
                'title'       => Yii::t('order', 'Title'),
                'description' => Yii::t('order', 'Description'),
            ];
        }
        
        /**
         * @return \yii\db\ActiveQuery
         */
        public function getLabel()
        {
            return $this->hasOne(Label::className(), [ 'id' => 'label_id' ]);
        }
        
        /**
         * @return \yii\db\ActiveQuery
         */
        public function getLanguage()
        {
            return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]);
        }
    }