<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "power_menu_t".
 *
 * @property integer $power_id
 * @property integer $menu_id
 */
class PowerMenuT extends \common\models\Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'power_menu_t';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['power_id', 'menu_id'], 'required'],
            [['power_id', 'menu_id'], 'integer'],
            [['power_id', 'menu_id'], 'unique', 'targetAttribute' => ['power_id', 'menu_id'], 'message' => 'The combination of Power ID and Menu ID has already been taken.'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'power_id' => 'Power ID',
            'menu_id' => 'Menu ID',
        ];
    }

    public function getMenus()
    {
        return $this->hasOne(MenuT::className(),['id'=>'menu_id']);
    }

    public function getPower()
    {
        return $this->hasOne(PowerT::className(),['id'=>'power_id']);
    }
}
