123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace app\cxinv\model;
- class UserRole extends Base
- {
- protected $schema = [
- 'id' =>'bigint',
- 'uid' =>'int',
- 'nickname' =>'varchar',
- 'roleid' =>'int',
- 'companyNo' =>'varchar',
- 'company_type' =>'tinyint',
- 'status' =>'tinyint',
- '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;
- }
- }
|