user(); $currentRole = $user->userRole(); // dd($currentRole, $roles); foreach ($currentRole as $role) { $roleValue = $role->value; if (!in_array($roleValue, $roles)) { throw new \App\Exceptions\RuntimeException('没有权限'); } } return $next($request); } }