- 在 AgentNodeProfileController 中添加对父代理能力授予的验证,确保子代理的权限在父代理范围内。 - 更新多个请求类,统一代理资料字段的验证逻辑,提升代码复用性。 - 引入 AgentProfileFieldRules 以简化代理资料更新请求的规则定义。 - 在 AgentProfile 模型中设置主键为 agent_node_id,确保与代理节点的关联性。 - 更新错误信息,增加对授信额度和占成比例的验证,确保数据一致性。
47 lines
1.8 KiB
PHP
47 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin;
|
|
|
|
use App\Http\Requests\Admin\Concerns\AgentProfileFieldRules;
|
|
use App\Http\Requests\ApiFormRequest;
|
|
use App\Rules\WalletApiUrlRule;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
final class AdminAgentLineStoreRequest extends ApiFormRequest
|
|
{
|
|
use AgentProfileFieldRules;
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
protected function prepareForValidation(): void
|
|
{
|
|
$this->prepareAgentProfileFieldsForValidation();
|
|
}
|
|
|
|
/** @return array<string, mixed> */
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'code' => ['required', 'string', 'max:64', 'regex:/^[a-z0-9][a-z0-9_-]*$/', Rule::unique('admin_sites', 'code')],
|
|
'name' => ['required', 'string', 'max:128'],
|
|
'username' => ['required', 'string', 'max:64'],
|
|
'password' => ['required', 'string', 'min:8', 'max:128'],
|
|
'email' => ['nullable', 'string', 'email', 'max:255', Rule::unique('admin_users', 'email')],
|
|
'currency_code' => ['sometimes', 'string', 'max:16'],
|
|
'status' => ['sometimes', 'integer', 'in:0,1'],
|
|
'wallet_api_url' => ['nullable', 'string', 'max:512', new WalletApiUrlRule()],
|
|
'wallet_debit_path' => ['sometimes', 'string', 'max:128'],
|
|
'wallet_credit_path' => ['sometimes', 'string', 'max:128'],
|
|
'wallet_balance_path' => ['sometimes', 'string', 'max:128'],
|
|
'wallet_timeout_seconds' => ['sometimes', 'integer', 'min:1', 'max:120'],
|
|
'iframe_allowed_origins' => ['nullable', 'array'],
|
|
'iframe_allowed_origins.*' => ['string', 'max:512'],
|
|
'lottery_h5_base_url' => ['nullable', 'string', 'max:512'],
|
|
'notes' => ['nullable', 'string', 'max:5000'],
|
|
...$this->agentProfileFieldRules(),
|
|
];
|
|
}
|
|
}
|