57 lines
1.9 KiB
PHP
57 lines
1.9 KiB
PHP
<?php
|
||
|
||
/**
|
||
* 文件功能:后台 VIP 支付配置保存请求
|
||
* 负责校验聊天室接入 NovaLink 支付中心所需的后台配置项
|
||
*/
|
||
|
||
namespace App\Http\Requests\Admin;
|
||
|
||
use Illuminate\Foundation\Http\FormRequest;
|
||
|
||
class UpdateVipPaymentConfigRequest extends FormRequest
|
||
{
|
||
/**
|
||
* 判断当前请求是否允许执行
|
||
*/
|
||
public function authorize(): bool
|
||
{
|
||
return true;
|
||
}
|
||
|
||
/**
|
||
* 获取表单校验规则
|
||
*
|
||
* @return array<string, array<int, string>>
|
||
*/
|
||
public function rules(): array
|
||
{
|
||
return [
|
||
'vip_payment_enabled' => ['required', 'in:0,1'],
|
||
'vip_payment_base_url' => ['nullable', 'url', 'max:255', 'required_if:vip_payment_enabled,1'],
|
||
'vip_payment_app_key' => ['nullable', 'string', 'max:100', 'required_if:vip_payment_enabled,1'],
|
||
'vip_payment_app_secret' => ['nullable', 'string', 'max:255', 'required_if:vip_payment_enabled,1'],
|
||
'vip_payment_timeout' => ['nullable', 'integer', 'min:3', 'max:30'],
|
||
];
|
||
}
|
||
|
||
/**
|
||
* 获取中文错误提示
|
||
*
|
||
* @return array<string, string>
|
||
*/
|
||
public function messages(): array
|
||
{
|
||
return [
|
||
'vip_payment_enabled.required' => '请先选择是否启用 VIP 支付',
|
||
'vip_payment_base_url.required_if' => '启用 VIP 支付时,支付中心地址不能为空',
|
||
'vip_payment_base_url.url' => '支付中心地址格式不正确',
|
||
'vip_payment_app_key.required_if' => '启用 VIP 支付时,App Key 不能为空',
|
||
'vip_payment_app_secret.required_if' => '启用 VIP 支付时,App Secret 不能为空',
|
||
'vip_payment_timeout.integer' => '请求超时时间必须是整数',
|
||
'vip_payment_timeout.min' => '请求超时时间不能小于 3 秒',
|
||
'vip_payment_timeout.max' => '请求超时时间不能大于 30 秒',
|
||
];
|
||
}
|
||
}
|