Role.php 555 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace app\common\model\supplier;
  3. use app\common\model\BaseModel;
  4. /**
  5. * 应用模型
  6. */
  7. class Role extends BaseModel
  8. {
  9. protected $name = 'supplier_role';
  10. protected $pk = 'role_id';
  11. /**
  12. * 关联权限
  13. * @return \think\model\relation\HasMany
  14. */
  15. public function access()
  16. {
  17. return $this->hasMany('RoleAccess', 'role_id', 'role_id');
  18. }
  19. /**
  20. * 获取详情
  21. */
  22. public static function detail($role_id)
  23. {
  24. return (new static())->with(['access'])->find($role_id);
  25. }
  26. }