<?php

namespace frontend\models;

use Yii;

/**
 * This is the model class for table "language".
 *
 * @property integer $language_id
 * @property string $lang_code
 * @property integer $is_default
 *
 * @property LanguageLang[] $languageLangs
 * @property OptionValues[] $optionValues
 */
class Language extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'language';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['lang_code', 'is_default'], 'required'],
            [['is_default'], 'integer'],
            [['lang_code'], 'string', 'max' => 4]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'language_id' => Yii::t('app', 'Language ID'),
            'lang_code' => Yii::t('app', 'Lang Code'),
            'is_default' => Yii::t('app', 'Is Default'),
        ];
    }

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

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getOptionValues()
    {
        return $this->hasMany(OptionValues::className(), ['option_language_id' => 'language_id']);
    }
}
