|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace common\models; |
| 4 | + |
| 5 | +use Yii; |
| 6 | + |
| 7 | +/** |
| 8 | + * This is the model class for table "auth_item". |
| 9 | + * |
| 10 | + * @property string $name |
| 11 | + * @property integer $type |
| 12 | + * @property string $description |
| 13 | + * @property string $rule_name |
| 14 | + * @property string $data |
| 15 | + * @property integer $created_at |
| 16 | + * @property integer $updated_at |
| 17 | + * |
| 18 | + * @property AuthAssignment[] $authAssignments |
| 19 | + * @property AuthRule $ruleName |
| 20 | + * @property AuthItemChild[] $authItemChildren |
| 21 | + * @property AuthItemChild[] $authItemChildren0 |
| 22 | + * @property AuthItem[] $children |
| 23 | + * @property AuthItem[] $parents |
| 24 | + */ |
| 25 | +class AuthItem extends \yii\db\ActiveRecord |
| 26 | +{ |
| 27 | + /** |
| 28 | + * @inheritdoc |
| 29 | + */ |
| 30 | + public static function tableName() |
| 31 | + { |
| 32 | + return 'auth_item'; |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * @inheritdoc |
| 37 | + */ |
| 38 | + public function rules() |
| 39 | + { |
| 40 | + return [ |
| 41 | + [['name', 'type'], 'required'], |
| 42 | + [['type', 'created_at', 'updated_at'], 'integer'], |
| 43 | + [['description', 'data'], 'string'], |
| 44 | + [['name', 'rule_name'], 'string', 'max' => 64], |
| 45 | + [['rule_name'], 'exist', 'skipOnError' => true, 'targetClass' => AuthRule::className(), 'targetAttribute' => ['rule_name' => 'name']], |
| 46 | + ]; |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * @inheritdoc |
| 51 | + */ |
| 52 | + public function attributeLabels() |
| 53 | + { |
| 54 | + return [ |
| 55 | + 'name' => 'Name', |
| 56 | + 'type' => 'Type', |
| 57 | + 'description' => 'Description', |
| 58 | + 'rule_name' => 'Rule Name', |
| 59 | + 'data' => 'Data', |
| 60 | + 'created_at' => 'Created At', |
| 61 | + 'updated_at' => 'Updated At', |
| 62 | + ]; |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * @return \yii\db\ActiveQuery |
| 67 | + */ |
| 68 | + public function getAuthAssignments() |
| 69 | + { |
| 70 | + return $this->hasMany(AuthAssignment::className(), ['item_name' => 'name']); |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * @return \yii\db\ActiveQuery |
| 75 | + */ |
| 76 | + public function getRuleName() |
| 77 | + { |
| 78 | + return $this->hasOne(AuthRule::className(), ['name' => 'rule_name']); |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * @return \yii\db\ActiveQuery |
| 83 | + */ |
| 84 | + public function getAuthItemChildren() |
| 85 | + { |
| 86 | + return $this->hasMany(AuthItemChild::className(), ['parent' => 'name']); |
| 87 | + } |
| 88 | + |
| 89 | + /** |
| 90 | + * @return \yii\db\ActiveQuery |
| 91 | + */ |
| 92 | + public function getAuthItemChildren0() |
| 93 | + { |
| 94 | + return $this->hasMany(AuthItemChild::className(), ['child' => 'name']); |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * @return \yii\db\ActiveQuery |
| 99 | + */ |
| 100 | + public function getChildren() |
| 101 | + { |
| 102 | + return $this->hasMany(AuthItem::className(), ['name' => 'child'])->viaTable('auth_item_child', ['parent' => 'name']); |
| 103 | + } |
| 104 | + |
| 105 | + /** |
| 106 | + * @return \yii\db\ActiveQuery |
| 107 | + */ |
| 108 | + public function getParents() |
| 109 | + { |
| 110 | + return $this->hasMany(AuthItem::className(), ['name' => 'parent'])->viaTable('auth_item_child', ['child' => 'name']); |
| 111 | + } |
| 112 | +} |
0 commit comments