v2board/app/Http/Controllers/Admin/ConfigController.php

91 lines
3.7 KiB
PHP
Raw Normal View History

2019-10-29 15:33:36 +08:00
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Requests\Admin\ConfigSave;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Plan;
use App\Models\Order;
use App\Models\User;
class ConfigController extends Controller
{
2020-01-11 13:36:52 +08:00
public function init()
{
2019-10-29 15:33:36 +08:00
}
2020-01-11 13:36:52 +08:00
public function fetch()
{
2019-10-29 15:33:36 +08:00
return response([
'data' => [
'invite' => [
2019-11-18 19:52:30 +08:00
'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)
2019-10-29 15:33:36 +08:00
],
'site' => [
2019-11-18 19:52:30 +08:00
'stop_register' => (int)config('v2board.stop_register', 0),
'email_verify' => (int)config('v2board.email_verify', 0),
'app_name' => config('v2board.app_name', 'V2Board'),
2019-11-23 23:29:22 +08:00
'app_url' => config('v2board.app_url'),
2019-11-24 23:21:29 +08:00
'subscribe_url' => config('v2board.subscribe_url'),
2020-01-12 02:02:45 +08:00
'plan_change_enable' => (int)config('v2board.plan_change_enable', 1),
2020-01-05 23:30:07 +08:00
'plan_transfer_hour' => config('v2board.plan_transfer_hour', 12),
2020-01-04 17:46:53 +08:00
'try_out_enable' => (int)config('v2board.try_out_enable', 0),
2020-01-04 17:21:46 +08:00
'try_out_plan_id' => (int)config('v2board.try_out_plan_id'),
2020-01-06 13:48:58 +08:00
'try_out_hour' => (int)config('v2board.try_out_hour', 1)
2019-10-29 15:33:36 +08:00
],
'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'),
2019-12-27 01:50:26 +08:00
'stripe_webhook_key' => config('v2board.stripe_webhook_key'),
// bitpayx
'bitpayx_enable' => config('v2board.bitpayx_enable'),
2020-01-14 00:29:59 +08:00
'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')
2019-10-29 15:33:36 +08:00
],
'server' => [
'server_token' => config('v2board.server_token')
2019-11-23 01:41:47 +08:00
],
'tutorial' => [
'apple_id' => config('v2board.apple_id')
2019-10-29 15:33:36 +08:00
]
]
]);
}
2020-01-11 13:36:52 +08:00
public function save(ConfigSave $request)
{
2019-10-29 15:33:36 +08:00
$data = $request->input();
$array = \Config::get('v2board');
foreach ($data as $k => $v) {
if (!in_array($k, ConfigSave::filter())) {
2020-01-04 18:11:13 +08:00
abort(500, '参数' . $k . '不在规则内,禁止修改');
2019-10-29 15:33:36 +08:00
}
$array[$k] = $v;
}
$data = var_export($array, 1);
2020-01-11 13:36:52 +08:00
if (!\File::put(base_path() . '/config/v2board.php', "<?php\n return $data ;")) {
2019-10-29 15:33:36 +08:00
abort(500, '修改失败');
}
\Artisan::call('config:cache');
return response([
'data' => true
]);
}
}