<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "menu_location".
 *
 * @property integer $menu_location_id
 * @property string $menu_location_name
 *
 * @property MenuLocationLang[] $menuLocationLangs
 * @property Language[] $langs
 */
class MenuLocation extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'menu_location';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['menu_location_id'], 'required'],
            [['menu_location_id'], 'integer'],
            [['menu_location_name'], 'string', 'max' => 250]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'menu_location_id' => Yii::t('app', 'Menu Location ID'),
            'menu_location_name' => Yii::t('app', 'Menu Location Name'),
        ];
    }

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

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