RoleService.php
546 Bytes
<?php
namespace App\Http\Services;
//后台用户相关信息服务
use Illuminate\Support\Facades\DB;
class RoleService
{
//根据user_id获取角色
public function getRolesByUserId($userId)
{
$bid = config('website.PermId');
$roleIds = DB::connection()->table('t_user_perm')->where('userId', $userId)->where('bid',$bid)->value('roles');
$roleIds = json_decode($roleIds, true);
return DB::connection()->table('t_role_perm')->where('bid',$bid)->whereIn('roleId', $roleIds)->pluck('name');
}
}