<?php namespace common\models; use Yii; /** * This is the model class for table "power_t". * * @property integer $id * @property string $name * @property string $created_at * @property string $updated_at */ class PowerT extends \common\models\Base { /** * @inheritdoc */ public static function tableName() { return 'power_t'; } /** * @inheritdoc */ public function rules() { return [ [['name'], 'required'], [['created_at', 'updated_at'], 'safe'], [['name'], 'string', 'max' => 100], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'name' => 'Name', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } public function getMenus() { return $this->hasMany(MenuT::className(),['id'=>'menu_id']) ->viaTable('power_menu_t',['power_id'=>'id']); } //获取所有权限组 static public function getTree($where='') { $power_info = PowerT::find()->where($where); $items = $power_info->all(); return $items; } }