<?php

namespace common\modules\blog\models;

use Yii;
use common\models\Language;

/**
 * This is the model class for table "article_lang".
 *
 * @property integer $article_language_id
 * @property integer $language_id
 * @property integer $article_id
 * @property string $text
 * @property string $seo_url
 * @property string $name
 * @property string $preview
 * @property string $meta_title
 * @property string $meta_descr
 * @property string $meta_keyword
 * @property string $h1_tag
 * @property string $tag
 *
 * @property Article $article
 * @property Language $lang
 */
class ArticleLang extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'article_lang';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['language_id', 'text', 'name'], 'required'],
            [['language_id', 'article_id'], 'integer'],
            [['text', 'seo_url', 'name', 'preview', 'meta_title', 'meta_descr', 'meta_keyword', 'h1_tag', 'tag'], 'string']
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'article_language_id' => Yii::t('app', 'ID'),
            'language_id' => Yii::t('app', 'Lang ID'),
            'article_id' => Yii::t('app', 'Article ID'),
            'text' => Yii::t('app', 'Text'),
            'seo_url' => Yii::t('app', 'Seo Url'),
            'name' => Yii::t('app', 'Name'),
            'preview' => Yii::t('app', 'Preview'),
            'meta_title' => Yii::t('app', 'Meta Title'),
            'meta_descr' => Yii::t('app', 'Meta Descr'),
            'meta_keyword' => Yii::t('app', 'Meta Keywords'),
            'h1_tag' => Yii::t('app', 'H1 Tag'),
            'tag' => Yii::t('app', 'Tags'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getArticle()
    {
        return $this->hasOne(Article::className(), ['article_id' => 'article_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getLang()
    {
        return $this->hasOne(Language::className(), ['language_id' => 'language_id']);
    }
}
