feat: 增强玩家端 API 鉴权中间件,支持多语言错误消息返回

This commit is contained in:
2026-05-08 15:20:36 +08:00
parent 9f8080cefe
commit fc0999664a
9 changed files with 199 additions and 4 deletions

View File

@@ -26,5 +26,15 @@ class AppServiceProvider extends ServiceProvider
/** @var Request $this */
return $this->attributes->get('lottery_player');
});
/**
* 【当前请求语言】zh / en / ne lottery.locales.supported 对齐。
* NegotiateLotteryLocale 写入 attribute控制台等非 HTTP 或无该中间件时回落到 fallback。
*/
Request::macro('lotteryLocale', function (): string {
/** @var Request $this */
return (string) ($this->attributes->get('lottery_locale')
?? config('lottery.locales.fallback', 'en'));
});
}
}