public function updateRegisterSetting(Request $request, Configuration $config) { $conf = $request->only([‘showTerms‘, ‘method‘, ‘content‘, ‘fixed‘, ‘type‘]); $settings = []; foreach ($conf as $key => $value) { $settings[‘registerSettings.‘.$key] = $value; } $config->set($settings); return response()->json([‘message‘ => ‘设置成功‘])->setStatusCode(201); } public function getRegisterSetting(Repository $con, Configuration $config) { $conf = $con->get(‘registerSettings‘); if (is_null($conf)) { $conf = $this->initRegisterConfiguration($config); } return response()->json($conf)->setStatusCode(200); } public function initRegisterConfiguration(Configuration $config_model) { $config = $config_model->getConfiguration(); $config->set(‘registerSettings.showTerms‘, ‘open‘); $config->set(‘registerSettings.method‘, ‘all‘); $config->set(‘registerSettings.fixed‘, ‘need‘); $config->set(‘registerSettings.type‘, ‘all‘); $config->set(‘registerSettings.content‘, ‘# 服务条款及隐私政策‘); // $configuration->save($config); return $config[‘registerSettings‘]; }
原文地址:https://www.cnblogs.com/sgm4231/p/10482305.html
时间: 2024-10-24 19:09:07