1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\model;
- use think\Model;
- /**
- * @mixin \think\Model
- */
- class UserRole extends Model
- {
-
- protected $updateTime='updatetime';
- protected $createTime='addtime';
- public static function GetRoleIdByCompnyNoAndUid($companyNo,$uid){
- return self::where([
- 'uid' => $uid,
- 'companyNo' => $companyNo,
- 'is_del' => 0])
- ->value('role_id','');
- }
- public function RoleInfo(){
- return $this->belongsTo(RoleAction::class,"roleid","role_id")->bind(['action_conllect']);
- }
- public static function getAllAction($uid=0,$companyNo='',$level=0){
- switch ($level){
- case 1:
- $action = Action::where(['is_del' => 0, 'status' => 1]) ->column('id');
- break;
- case 2:
- $role = self::where([
- 'uid' => $uid,
- 'companyNo' => $companyNo,
- 'is_del' => 0])->with('RoleInfo')
- ->findOrEmpty();
- $action = $role->action_conllect??[];
- break;
- case 3:
- $role = self::where([
- 'uid' => $uid,
- 'is_del' => 0])->with('RoleInfo')
- ->findOrEmpty();
- $action = $role->action_conllect??[];
- break;
- default:
- $action = [];
- }
- return $action;
- }
- }
|