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