AdminRole.php 952 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Models;
  3. class AdminRole extends Model
  4. {
  5. protected $fillable = ['name', 'slug', 'admin_id', 'merchant_id'];
  6. const AREA_ADMIN = 'admin-area';
  7. const ADMINISTROTOR = 'administrator'; // 技术管理员
  8. const MERCHANTSADMIN = 'merchantsAdmin'; // 商户管理员
  9. const NORMALADMINISTRATOR = 'normalAdministrator';// 超级管理员
  10. public function permissions()
  11. {
  12. return $this->belongsToMany(
  13. AdminPermission::class,
  14. 'admin_role_permission',
  15. 'role_id',
  16. 'permission_id'
  17. );
  18. }
  19. public function vue_routers()
  20. {
  21. return $this->belongsToMany(
  22. VueRouter::class,
  23. 'vue_router_role',
  24. 'role_id',
  25. 'vue_router_id'
  26. );
  27. }
  28. public function delete()
  29. {
  30. $this->permissions()->detach();
  31. $this->vue_routers()->detach();
  32. return parent::delete();
  33. }
  34. }