- 管理端账号/代理/站点等密码最短长度统一为 6 位 - LotterySettings、审计日志展示、币种与报表接口等小修复 - 补充设置批量更新、注单、校验错误等相关测试
62 lines
2.0 KiB
PHP
62 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\Concerns;
|
|
|
|
trait AdminAccountFieldRules
|
|
{
|
|
/** @return array<int, mixed> */
|
|
protected function adminLoginAccountRules(bool $required = true): array
|
|
{
|
|
$rules = ['string', 'min:2', 'max:64', 'regex:/^[a-zA-Z0-9._-]+$/u'];
|
|
|
|
return $required ? array_merge(['required'], $rules) : array_merge(['sometimes'], $rules);
|
|
}
|
|
|
|
/** @return array<int, mixed> */
|
|
protected function adminLoginPasswordRules(bool $required = true, int $min = 6, int $max = 256): array
|
|
{
|
|
$rules = ['string', 'min:'.$min, 'max:'.$max];
|
|
|
|
if ($required) {
|
|
return array_merge(['required'], $rules);
|
|
}
|
|
|
|
return array_merge(['sometimes', 'nullable'], $rules);
|
|
}
|
|
|
|
/** @return array<int, mixed> */
|
|
protected function adminOperatorUsernameRules(bool $required = true): array
|
|
{
|
|
$rules = ['string', 'min:2', 'max:64', 'regex:/^[a-zA-Z0-9._-]+$/u'];
|
|
|
|
return $required ? array_merge(['required'], $rules) : array_merge(['sometimes'], $rules);
|
|
}
|
|
|
|
/** @return array<int, mixed> */
|
|
protected function nativePlayerUsernameRules(bool $required = false): array
|
|
{
|
|
$rules = ['string', 'min:2', 'max:64', 'regex:/^[a-zA-Z0-9._-]+$/u'];
|
|
|
|
return $required ? array_merge(['required'], $rules) : array_merge(['nullable'], $rules);
|
|
}
|
|
|
|
/** @return array<int, mixed> */
|
|
protected function nativePlayerPasswordRules(bool $required = false): array
|
|
{
|
|
$rules = ['string', 'min:6', 'max:128'];
|
|
|
|
return $required ? array_merge(['required'], $rules) : array_merge(['nullable'], $rules);
|
|
}
|
|
|
|
protected function normalizeAdminAccountFields(): void
|
|
{
|
|
if ($this->has('account')) {
|
|
$this->merge(['account' => strtolower(trim((string) $this->input('account')))]);
|
|
}
|
|
|
|
if ($this->has('username')) {
|
|
$this->merge(['username' => strtolower(trim((string) $this->input('username')))]);
|
|
}
|
|
}
|
|
}
|