- 在多个控制器中更新权限检查逻辑,确保管理员能够更灵活地管理代理和玩家。 - 在 AdminPlayerStoreController 中引入对玩家创建能力的验证,确保只有具备相应权限的管理员能够创建玩家。 - 更新请求验证逻辑,新增 credit_limit、rebate_rate 和 extra_rebate_rate 字段,以支持更细粒度的玩家管理。 - 在 AgentNodeProfileController 中添加对父代理能力授予的验证,确保子代理的权限在父代理范围内。 - 引入 AgentProfileFieldRules 以简化代理资料更新请求的规则定义,提升代码复用性。
61 lines
1.6 KiB
PHP
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:8', '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'],
|
|
];
|
|
}
|
|
}
|