This commit is contained in:
Tokumeikoi 2020-01-31 17:13:30 +08:00
parent 2f8f3afebf
commit 51bb2779b9
4 changed files with 95 additions and 93 deletions

View File

@ -7,7 +7,7 @@ APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=db
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
@ -45,4 +45,4 @@ PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

View File

@ -16,74 +16,24 @@ class ConfigController extends Controller
public function fetch()
{
return response([
'data' => [
'invite' => [
'invite_force' => (int)config('v2board.invite_force', 0),
'invite_commission' => config('v2board.invite_commission', 10),
'invite_gen_limit' => config('v2board.invite_gen_limit', 5),
'invite_never_expire' => config('v2board.invite_never_expire', 0)
],
'site' => [
'stop_register' => (int)config('v2board.stop_register', 0),
'email_verify' => (int)config('v2board.email_verify', 0),
'app_name' => config('v2board.app_name', 'V2Board'),
'app_url' => config('v2board.app_url'),
'subscribe_url' => config('v2board.subscribe_url'),
'plan_change_enable' => (int)config('v2board.plan_change_enable', 1),
'plan_transfer_hour' => config('v2board.plan_transfer_hour', 12),
'try_out_enable' => (int)config('v2board.try_out_enable', 0),
'try_out_plan_id' => (int)config('v2board.try_out_plan_id'),
'try_out_hour' => (int)config('v2board.try_out_hour', 1)
],
'pay' => [
// alipay
'alipay_enable' => (int)config('v2board.alipay_enable'),
'alipay_appid' => config('v2board.alipay_appid'),
'alipay_pubkey' => config('v2board.alipay_pubkey'),
'alipay_privkey' => config('v2board.alipay_privkey'),
// stripe
'stripe_sk_live' => config('v2board.stripe_sk_live'),
'stripe_pk_live' => config('v2board.stripe_pk_live'),
'stripe_alipay_enable' => (int)config('v2board.stripe_alipay_enable'),
'stripe_wepay_enable' => (int)config('v2board.stripe_wepay_enable'),
'stripe_webhook_key' => config('v2board.stripe_webhook_key'),
// bitpayx
'bitpayx_enable' => config('v2board.bitpayx_enable'),
'bitpayx_appsecret' => config('v2board.bitpayx_appsecret'),
// paytaro
'paytaro_enable' => config('v2board.paytaro_enable'),
'paytaro_app_id' => config('v2board.paytaro_app_id'),
'paytaro_app_secret' => config('v2board.paytaro_app_secret')
],
'frontend' => [
'frontend_theme' => config('v2board.frontend_theme', 1),
'frontend_background_url' => config('v2board.frontend_background_url')
],
'server' => [
'server_token' => config('v2board.server_token'),
'server_license' => config('v2board.server_license')
],
'tutorial' => [
'apple_id' => config('v2board.apple_id')
]
]
'data' => config('v2board')
]);
}
public function save(ConfigSave $request)
{
$data = $request->input();
$array = \Config::get('v2board');
// $array = \Config::get('v2board');
foreach ($data as $k => $v) {
if (!in_array($k, ConfigSave::filter())) {
abort(500, '参数' . $k . '不在规则内,禁止修改');
}
$array[$k] = $v;
}
$data = var_export($array, 1);
if (!\File::put(base_path() . '/config/v2board.php', "<?php\n return $data ;")) {
abort(500, '修改失败');
config(['v2board.' . $k => $v]);
}
// $data = var_export($array, 1);
// if (!\File::put(base_path() . '/config/v2board.php', "<?php\n return $data ;")) {
// abort(500, '修改失败');
// }
\Artisan::call('config:cache');
return response([
'data' => true

View File

@ -7,47 +7,47 @@ use Illuminate\Foundation\Http\FormRequest;
class ConfigSave extends FormRequest
{
CONST RULES = [
'invite_force' => 'in:0,1',
'invite_commission' => 'integer',
'invite_gen_limit' => 'integer',
'invite_never_expire' => 'in:0,1',
'stop_register' => 'in:0,1',
'email_verify' => 'in:0,1',
'app_name' => '',
'app_url' => 'url',
'subscribe_url' => 'url',
'plan_transfer_hour' => 'numeric',
'plan_change_enable' => 'in:0,1',
'try_out_enable' => 'in:0,1',
'try_out_plan_id' => 'integer',
'try_out_hour' => 'numeric',
'invite.invite_force' => 'in:0,1',
'invite.invite_commission' => 'integer',
'invite.invite_gen_limit' => 'integer',
'invite.invite_never_expire' => 'in:0,1',
'site.stop_register' => 'in:0,1',
'site.email_verify' => 'in:0,1',
'site.app_name' => '',
'site.app_url' => 'url',
'site.subscribe_url' => 'url',
'site.plan_transfer_hour' => 'numeric',
'site.plan_change_enable' => 'in:0,1',
'site.try_out_enable' => 'in:0,1',
'site.try_out_plan_id' => 'integer',
'site.try_out_hour' => 'numeric',
// server
'server_token' => 'nullable|min:16',
'server_license' => 'nullable',
'server.server_token' => 'nullable|min:16',
'server.server_license' => 'nullable',
// alipay
'alipay_enable' => 'in:0,1',
'alipay_appid' => 'nullable|integer|min:16',
'alipay_pubkey' => 'max:2048',
'alipay_privkey' => 'max:2048',
'pay.alipay_enable' => 'in:0,1',
'pay.alipay_appid' => 'nullable|integer|min:16',
'pay.alipay_pubkey' => 'max:2048',
'pay.alipay_privkey' => 'max:2048',
// stripe
'stripe_alipay_enable' => 'in:0,1',
'stripe_wepay_enable' => 'in:0,1',
'stripe_sk_live' => '',
'stripe_pk_live' => '',
'stripe_webhook_key' => '',
'pay.stripe_alipay_enable' => 'in:0,1',
'pay.stripe_wepay_enable' => 'in:0,1',
'pay.stripe_sk_live' => '',
'pay.stripe_pk_live' => '',
'pay.stripe_webhook_key' => '',
// bitpayx
'bitpayx_enable' => 'in:0,1',
'bitpayx_appsecret' => '',
'pay.bitpayx_enable' => 'in:0,1',
'pay.bitpayx_appsecret' => '',
// paytaro
'paytaro_enable' => 'in:0,1',
'paytaro_app_id' => '',
'paytaro_app_secret' => '',
'pay.paytaro_enable' => 'in:0,1',
'pay.paytaro_app_id' => '',
'pay.paytaro_app_secret' => '',
// frontend
'frontend_theme' => 'in:1,2',
'frontend_background_url' => 'nullable|url',
'frontend.frontend_theme' => 'in:1,2',
'frontend.frontend_background_url' => 'nullable|url',
// tutorial
'apple_id' => 'email',
'apple_id_password' => ''
'tutorial.apple_id' => 'email',
'tutorial.apple_id_password' => ''
];
public static function filter()

52
config/v2board.php Normal file
View File

@ -0,0 +1,52 @@
<?php
return [
'invite' => [
'invite_force' => 0,
'invite_commission' => 10,
'invite_gen_limit' => 5,
'invite_never_expire' => 0
],
'site' => [
'stop_register' => 0,
'email_verify' => 0,
'app_name' => 'V2Board',
'app_url' => '',
'subscribe_url' => '',
'plan_change_enable' => 1,
'plan_transfer_hour' => 12,
'try_out_enable' => 0,
'try_out_plan_id' => '',
'try_out_hour' => 1
],
'pay' => [
// alipay
'alipay_enable' => '',
'alipay_appid' => '',
'alipay_pubkey' => '',
'alipay_privkey' => '',
// stripe
'stripe_sk_live' => '',
'stripe_pk_live' => '',
'stripe_alipay_enable' => 0,
'stripe_wepay_enable' => 0,
'stripe_webhook_key' => '',
// bitpayx
'bitpayx_enable' => '',
'bitpayx_appsecret' => '',
// paytaro
'paytaro_enable' => 0,
'paytaro_app_id' => '',
'paytaro_app_secret' => ''
],
'frontend' => [
'frontend_theme' => 1,
'frontend_background_url' => ''
],
'server' => [
'server_token' => '',
'server_license' => ''
],
'tutorial' => [
'apple_id' => ''
]
];