v2board/app/Http/Requests/Admin/ConfigSave.php

115 lines
4.2 KiB
PHP
Raw Normal View History

2019-10-29 15:33:36 +08:00
<?php
namespace App\Http\Requests\Admin;
use Illuminate\Foundation\Http\FormRequest;
class ConfigSave extends FormRequest
{
2022-05-09 00:26:38 +08:00
const RULES = [
// invite & commission
'invite_force' => 'in:0,1',
'invite_commission' => 'integer',
'invite_gen_limit' => 'integer',
'invite_never_expire' => 'in:0,1',
'commission_first_time_enable' => 'in:0,1',
'commission_auto_check_enable' => 'in:0,1',
'commission_withdraw_limit' => 'nullable|numeric',
'commission_withdraw_method' => 'nullable|array',
'withdraw_close_enable' => 'in:0,1',
'commission_distribution_enable' => 'in:0,1',
'commission_distribution_l1' => 'nullable|numeric',
'commission_distribution_l2' => 'nullable|numeric',
'commission_distribution_l3' => 'nullable|numeric',
// site
2022-05-15 01:46:35 +08:00
'logo' => 'nullable|url',
2022-05-09 23:46:33 +08:00
'force_https' => 'in:0,1',
'safe_mode_enable' => 'in:0,1',
2022-05-09 00:26:38 +08:00
'stop_register' => 'in:0,1',
'email_verify' => 'in:0,1',
'app_name' => '',
'app_description' => '',
'app_url' => 'nullable|url',
'subscribe_url' => 'nullable',
'try_out_enable' => 'in:0,1',
'try_out_plan_id' => 'integer',
'try_out_hour' => 'numeric',
'email_whitelist_enable' => 'in:0,1',
'email_whitelist_suffix' => 'nullable|array',
'email_gmail_limit_enable' => 'in:0,1',
'recaptcha_enable' => 'in:0,1',
'recaptcha_key' => '',
'recaptcha_site_key' => '',
'tos_url' => 'nullable|url',
'currency' => '',
'currency_symbol' => '',
'register_limit_by_ip_enable' => 'in:0,1',
'register_limit_count' => 'integer',
'register_limit_expire' => 'integer',
2022-12-16 00:37:33 +08:00
'secure_path' => 'min:8|regex:/^[\w-]*$/',
2022-05-09 00:26:38 +08:00
// subscribe
'plan_change_enable' => 'in:0,1',
2022-06-08 02:19:19 +08:00
'reset_traffic_method' => 'in:0,1,2,3,4',
2022-05-09 00:26:38 +08:00
'surplus_enable' => 'in:0,1',
'new_order_event_id' => 'in:0,1',
'renew_order_event_id' => 'in:0,1',
'change_order_event_id' => 'in:0,1',
'show_info_to_server_enable' => 'in:0,1',
2022-05-09 00:26:38 +08:00
// server
'server_token' => 'nullable|min:16',
2022-11-27 23:50:07 +08:00
'server_pull_interval' => 'integer',
'server_push_interval' => 'integer',
2022-05-09 00:26:38 +08:00
// frontend
'frontend_theme' => '',
2022-12-15 01:03:05 +08:00
'frontend_theme_sidebar' => 'nullable|in:dark,light',
'frontend_theme_header' => 'nullable|in:dark,light',
'frontend_theme_color' => 'nullable|in:default,darkblue,black,green',
2022-05-09 23:46:33 +08:00
'frontend_background_url' => 'nullable|url',
2022-05-09 00:26:38 +08:00
// email
'email_template' => '',
'email_host' => '',
'email_port' => '',
'email_username' => '',
'email_password' => '',
'email_encryption' => '',
'email_from_address' => '',
// telegram
'telegram_bot_enable' => 'in:0,1',
'telegram_bot_token' => '',
'telegram_discuss_id' => '',
'telegram_channel_id' => '',
'telegram_discuss_link' => 'nullable|url',
// app
'windows_version' => '',
'windows_download_url' => '',
'macos_version' => '',
'macos_download_url' => '',
'android_version' => '',
'android_download_url' => ''
];
2019-10-29 15:33:36 +08:00
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
2022-05-09 00:26:38 +08:00
return self::RULES;
2019-10-29 15:33:36 +08:00
}
2020-01-11 13:36:52 +08:00
2019-10-29 15:33:36 +08:00
public function messages()
{
2020-03-02 00:14:58 +08:00
// illiteracy prompt
2019-10-29 15:33:36 +08:00
return [
2020-03-02 00:14:58 +08:00
'app_url.url' => '站点URL格式不正确必须携带http(s)://',
2021-03-26 01:20:53 +08:00
'subscribe_url.url' => '订阅URL格式不正确必须携带http(s)://',
2021-05-06 23:12:58 +08:00
'server_token.min' => '通讯密钥长度必须大于16位',
2021-12-17 01:53:03 +08:00
'tos_url.url' => '服务条款URL格式不正确必须携带http(s)://',
2022-05-15 01:46:35 +08:00
'telegram_discuss_link.url' => 'Telegram群组地址必须为URL格式必须携带http(s)://',
'logo.url' => 'LOGO URL格式不正确必须携带https(s)://',
2022-12-16 00:37:33 +08:00
'secure_path.min' => '后台路径长度最小为8位',
'secure_path.regex' => '后台路径只能为字母或数字'
2019-10-29 15:33:36 +08:00
];
}
}