Files
lotteryLaravel/app/Http/Requests/Admin/AdminUserStoreRequest.php
kang 3f04b4ebe3
Some checks failed
lotterLaravel CI / test (push) Has been cancelled
lotterLaravel E2E / e2e-api (push) Has been cancelled
feat(admin): 密码校验统一与后台 API/设置增强
- 管理端账号/代理/站点等密码最短长度统一为 6 位
- LotterySettings、审计日志展示、币种与报表接口等小修复
- 补充设置批量更新、注单、校验错误等相关测试
2026-06-26 14:39:22 +08:00

61 lines
1.6 KiB
PHP

<?php
namespace App\Http\Requests\Admin;
use Illuminate\Support\Str;
use App\Http\Requests\ApiFormRequest;
/**
* 管理员用户创建请求。
*
* @see AdminUserStoreController
*/
final class AdminUserStoreRequest extends ApiFormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Prepare the data for validation.
*/
protected function prepareForValidation(): void
{
$username = $this->input('username');
if (is_string($username)) {
$this->merge([
'username' => Str::lower(trim($username)),
]);
}
if ($this->input('email') === '') {
$this->merge([
'email' => null,
]);
}
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, array<int, mixed>>
*/
public function rules(): array
{
return [
'username' => ['required', 'string', 'min:2', 'max:64', 'regex:/^[a-zA-Z0-9._-]+$/u', 'unique:admin_users,username'],
'nickname' => ['required', 'string', 'max:128'],
'email' => ['nullable', 'string', 'email', 'max:255'],
'password' => ['required', 'string', 'min:6', 'max:256'],
'status' => ['sometimes', 'integer', 'in:0,1'],
'admin_site_id' => ['required', 'integer', 'exists:admin_sites,id'],
'role_slugs' => ['required', 'array', 'min:1'],
'role_slugs.*' => ['string', 'max:64', 'distinct', 'exists:admin_roles,slug'],
];
}
}