SaasAuthRole.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * 厦门云联储网络科技有限公司
  4. * https://www.baokuaiyun.com
  5. * Copyright (c) 2023 爆块云 All rights reserved.
  6. */
  7. namespace app\models;
  8. use yii\db\ActiveRecord;
  9. use yii\behaviors\TimestampBehavior;
  10. /**
  11. * Class AuthRole
  12. * @package app\modules\common\models
  13. * @property string $id
  14. * @property string $name
  15. * @property string $data
  16. * @property string $edit_data
  17. * @property string $describe
  18. * @property integer $status
  19. * @property string $created_at
  20. * @property string $updated_at
  21. */
  22. class SaasAuthRole extends ActiveRecord
  23. {
  24. const STATUS_NORMAL = 1; // 正常
  25. const STATUS_DISABLE = 0; // 禁用
  26. public static function tableName()
  27. {
  28. return '{{%saas_auth_role}}';
  29. }
  30. public function behaviors()
  31. {
  32. return [
  33. [
  34. // 自动更新创建和更新时间
  35. 'class' => TimestampBehavior::class,
  36. 'value' => date("Y-m-d H:i:s")
  37. ]
  38. ];
  39. }
  40. public function rules()
  41. {
  42. return [
  43. [['id', 'status'], 'integer'],
  44. [['name'], 'string', 'max' => 64],
  45. [['name', 'data'], 'required'],
  46. [['data', 'edit_data'], 'string'],
  47. [['describe'], 'string', 'max' => 255],
  48. [['create_at', 'update_at'], 'safe']
  49. ];
  50. }
  51. public function attributeLabels()
  52. {
  53. return [
  54. 'id' => 'ID',
  55. 'name' => '角色名称',
  56. 'create_at' => '创建时间',
  57. 'update_at' => '更新时间',
  58. 'data' => '角色数据',
  59. 'edit_data' => '角色数据',
  60. 'describe' => '简介',
  61. 'status' => '状态'
  62. ];
  63. }
  64. /**
  65. * 获取管理员
  66. * @return \yii\db\ActiveQuery
  67. * @throws \yii\base\InvalidConfigException
  68. */
  69. public function getAdmins()
  70. {
  71. return $this->hasMany(Admin::class, ['id' => 'admin_id'])
  72. ->viaTable('{{%saas_admin_role}}', ['role_id' => 'id']);
  73. }
  74. }