ConfigSave.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. namespace App\Http\Requests\Admin;
  3. use Illuminate\Foundation\Http\FormRequest;
  4. class ConfigSave extends FormRequest
  5. {
  6. const RULES = [
  7. // invite & commission
  8. 'invite_force' => 'in:0,1',
  9. 'invite_commission' => 'integer',
  10. 'invite_gen_limit' => 'integer',
  11. 'invite_never_expire' => 'in:0,1',
  12. 'commission_first_time_enable' => 'in:0,1',
  13. 'commission_auto_check_enable' => 'in:0,1',
  14. 'commission_withdraw_limit' => 'nullable|numeric',
  15. 'commission_withdraw_method' => 'nullable|array',
  16. 'withdraw_close_enable' => 'in:0,1',
  17. 'commission_distribution_enable' => 'in:0,1',
  18. 'commission_distribution_l1' => 'nullable|numeric',
  19. 'commission_distribution_l2' => 'nullable|numeric',
  20. 'commission_distribution_l3' => 'nullable|numeric',
  21. // site
  22. 'logo' => 'nullable|url',
  23. 'force_https' => 'in:0,1',
  24. 'stop_register' => 'in:0,1',
  25. 'app_name' => '',
  26. 'app_description' => '',
  27. 'app_url' => 'nullable|url',
  28. 'subscribe_url' => 'nullable',
  29. 'subscribe_path' => 'nullable',
  30. 'try_out_enable' => 'in:0,1',
  31. 'try_out_plan_id' => 'integer',
  32. 'try_out_hour' => 'numeric',
  33. 'tos_url' => 'nullable|url',
  34. 'currency' => '',
  35. 'currency_symbol' => '',
  36. // subscribe
  37. 'plan_change_enable' => 'in:0,1',
  38. 'reset_traffic_method' => 'in:0,1,2,3,4',
  39. 'new_order_event_id' => 'in:0,1',
  40. 'renew_order_event_id' => 'in:0,1',
  41. 'change_order_event_id' => 'in:0,1',
  42. 'show_info_to_server_enable' => 'in:0,1',
  43. // server
  44. 'server_token' => 'nullable|min:16',
  45. 'server_pull_interval' => 'integer',
  46. 'server_push_interval' => 'integer',
  47. // frontend
  48. 'frontend_theme' => '',
  49. 'frontend_theme_sidebar' => 'nullable|in:dark,light',
  50. 'frontend_theme_header' => 'nullable|in:dark,light',
  51. 'frontend_theme_color' => 'nullable|in:default,darkblue,black,green',
  52. 'frontend_background_url' => 'nullable|url',
  53. // email
  54. 'email_template' => '',
  55. 'email_host' => '',
  56. 'email_port' => '',
  57. 'email_username' => '',
  58. 'email_password' => '',
  59. 'email_encryption' => '',
  60. 'email_from_address' => '',
  61. // telegram
  62. 'telegram_bot_enable' => 'in:0,1',
  63. 'telegram_bot_token' => '',
  64. 'telegram_discuss_id' => '',
  65. 'telegram_channel_id' => '',
  66. 'telegram_discuss_link' => 'nullable|url',
  67. // app
  68. 'windows_version' => '',
  69. 'windows_download_url' => '',
  70. 'macos_version' => '',
  71. 'macos_download_url' => '',
  72. 'android_version' => '',
  73. 'android_download_url' => '',
  74. // safe
  75. 'email_whitelist_enable' => 'in:0,1',
  76. 'email_whitelist_suffix' => 'nullable|array',
  77. 'email_gmail_limit_enable' => 'in:0,1',
  78. 'recaptcha_enable' => 'in:0,1',
  79. 'recaptcha_key' => '',
  80. 'recaptcha_site_key' => '',
  81. 'email_verify' => 'in:0,1',
  82. 'safe_mode_enable' => 'in:0,1',
  83. 'register_limit_by_ip_enable' => 'in:0,1',
  84. 'register_limit_count' => 'integer',
  85. 'register_limit_expire' => 'integer',
  86. 'secure_path' => 'min:8|regex:/^[\w-]*$/',
  87. 'password_limit_enable' => 'in:0,1',
  88. 'password_limit_count' => 'integer',
  89. 'password_limit_expire' => 'integer',
  90. ];
  91. /**
  92. * Get the validation rules that apply to the request.
  93. *
  94. * @return array
  95. */
  96. public function rules()
  97. {
  98. return self::RULES;
  99. }
  100. public function messages()
  101. {
  102. // illiteracy prompt
  103. return [
  104. 'app_url.url' => '站点URL格式不正确,必须携带http(s)://',
  105. 'subscribe_url.url' => '订阅URL格式不正确,必须携带http(s)://',
  106. 'server_token.min' => '通讯密钥长度必须大于16位',
  107. 'tos_url.url' => '服务条款URL格式不正确,必须携带http(s)://',
  108. 'telegram_discuss_link.url' => 'Telegram群组地址必须为URL格式,必须携带http(s)://',
  109. 'logo.url' => 'LOGO URL格式不正确,必须携带https(s)://',
  110. 'secure_path.min' => '后台路径长度最小为8位',
  111. 'secure_path.regex' => '后台路径只能为字母或数字'
  112. ];
  113. }
  114. }