UserRole.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\admin\model;
  4. use think\Model;
  5. /**
  6. * @mixin \think\Model
  7. */
  8. class UserRole extends Model
  9. {
  10. protected $updateTime='updatetime';
  11. protected $createTime='addtime';
  12. public static function GetRoleIdByCompnyNoAndUid($companyNo,$uid){
  13. return self::where([
  14. 'uid' => $uid,
  15. 'companyNo' => $companyNo,
  16. 'is_del' => 0])
  17. ->value('role_id','');
  18. }
  19. public function RoleInfo(){
  20. return $this->belongsTo(RoleAction::class,"roleid","role_id")->bind(['action_conllect']);
  21. }
  22. public static function getAllAction($uid=0,$companyNo='',$level=0){
  23. switch ($level){
  24. case 1:
  25. $action = Action::where(['is_del' => 0, 'status' => 1]) ->column('id');
  26. break;
  27. case 2:
  28. $role = self::where([
  29. 'uid' => $uid,
  30. 'companyNo' => $companyNo,
  31. 'is_del' => 0])->with('RoleInfo')
  32. ->findOrEmpty();
  33. $action = $role->action_conllect??[];
  34. break;
  35. case 3:
  36. $role = self::where([
  37. 'uid' => $uid,
  38. 'is_del' => 0])->with('RoleInfo')
  39. ->findOrEmpty();
  40. $action = $role->action_conllect??[];
  41. break;
  42. default:
  43. $action = [];
  44. }
  45. return $action;
  46. }
  47. }