123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace app\cxinv\model;
- class UserRole extends Base
- {
- //设置字段信息
- protected $schema = [
- 'id' =>'bigint',//
- 'uid' =>'int',//
- 'nickname' =>'varchar',//账户名称
- 'roleid' =>'int',//角色id
- 'companyNo' =>'varchar',//关联企业编号
- 'company_type' =>'tinyint',//业务公司类型1业务公司 2供应商 0 无关联
- 'status' =>'tinyint',//状态 0禁用 1可用
- 'is_main' =>'tinyint',//是否默认角色
- 'is_del' =>'tinyint',//是否删除
- 'addtime' =>'datetime',//新建时间
- 'updatetime' =>'datetime',//更新时间
- ];
- 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;
- }
- }
|