<?php
    
    namespace common\models\slider;
    
    use artbox\core\models\Image;
    use artbox\core\models\Language;
    use Yii;
    use yii\db\ActiveRecord;
    
    /**
     * This is the model class for table "slide_lang".
     *
     * @property integer  $slide_id
     * @property integer  $language_id
     * @property string   $link
     * @property integer  $image_id
     * @property string   $title
     * @property Image    $image
     * @property Language $language
     * @property Slide    $slide
     */
    class SlideLang extends ActiveRecord
    {
        /**
         * @inheritdoc
         */
        public static function tableName()
        {
            return 'slide_lang';
        }
        
        /**
         * @inheritdoc
         */
        public function rules()
        {
            return [
                [
                    [
                        'image_id',
                    ],
                    'integer',
                ],
                [
                    [
                        'link',
                        'title',
                    ],
                    'string',
                    'max' => 255,
                ],
                [
                   [ 'description' ],
                   'string'
                ]
            ];
        }
        
        /**
         * @inheritdoc
         */
        public function attributeLabels()
        {
            return [
                'slide_id'    => Yii::t('core', 'Slide ID'),
                'language_id' => Yii::t('core', 'Language ID'),
                'link'        => Yii::t('core', 'Link'),
                'image_id'    => Yii::t('core', 'Image'),
                'title'       => Yii::t('core', 'Title'),
                'description'       => Yii::t('core', 'Description'),
            ];
        }
        
        /**
         * @return \yii\db\ActiveQuery
         */
        public function getImage()
        {
            return $this->hasOne(Image::className(), [ 'id' => 'image_id' ]);
        }
        
        /**
         * @return \yii\db\ActiveQuery
         */
        public function getLanguage()
        {
            return $this->hasOne(Language::className(), [ 'id' => 'language_id' ]);
        }
        
        /**
         * @return \yii\db\ActiveQuery
         */
        public function getSlide()
        {
            return $this->hasOne(Slide::className(), [ 'id' => 'slide_id' ])
                        ->inverseOf('slideLangs');
        }
    
        public static function primaryKey()
        {
            return ['slide_id', 'language_id'];
        }
    
    }
