AuthAssignment.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace common\models\rbac;
  3. use Yii;
  4. /**
  5. * This is the model class for table "{{%rbac_auth_assignment}}".
  6. *
  7. *
  8. * @property int $role_id
  9. * @property int $user_id
  10. * @property string $app_id 类型
  11. */
  12. class AuthAssignment extends \common\models\base\BaseActiveRecord
  13. {
  14. /**
  15. * {@inheritdoc}
  16. */
  17. public static function tableName()
  18. {
  19. return '{{%rbac_auth_assignment}}';
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function rules()
  25. {
  26. return [
  27. [['role_id', 'user_id'], 'required'],
  28. [['role_id', 'user_id'], 'integer'],
  29. [['app_id'], 'string', 'max' => 20],
  30. ];
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function attributeLabels()
  36. {
  37. return [
  38. 'role_id' => '角色id',
  39. 'user_id' => '用户id',
  40. 'app_id' => '类型',
  41. ];
  42. }
  43. /**
  44. * @return \yii\db\ActiveQuery
  45. */
  46. public function getRole()
  47. {
  48. return $this->hasOne(AuthRole::class, ['id' => 'role_id'])
  49. ->andFilterWhere(['merchant_id' => Yii::$app->services->merchant->getId()]);
  50. }
  51. }