AuthItem.php 2.7 KB

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