Initial commit,修正
This commit is contained in:
Executable
+70
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "auth_item_child".
|
||||
*
|
||||
* @property string $parent
|
||||
* @property string $child
|
||||
*
|
||||
* @property AuthItem $parent0
|
||||
* @property AuthItem $child0
|
||||
*/
|
||||
class AuthItemChild extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%auth_item_child}}';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['parent', 'child'], 'required'],
|
||||
[['parent', 'child'], 'string', 'max' => 64],
|
||||
[['parent'], 'exist', 'skipOnError' => true, 'targetClass' => AuthItem::className(), 'targetAttribute' => ['parent' => 'name']],
|
||||
[['child'], 'exist', 'skipOnError' => true, 'targetClass' => AuthItem::className(), 'targetAttribute' => ['child' => 'name']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'parent' => 'Parent',
|
||||
'child' => 'Child',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getParent0()
|
||||
{
|
||||
return $this->hasOne(AuthItem::className(), ['name' => 'parent']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getChild0()
|
||||
{
|
||||
return $this->hasOne(AuthItem::className(), ['name' => 'child']);
|
||||
}
|
||||
|
||||
public function getPermission($id){
|
||||
$permission = self::find()->where(['parent'=>$id])->asArray()->all();
|
||||
return $permission;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user