laravel 配置设置
Posted 心之所依
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了laravel 配置设置相关的知识,希望对你有一定的参考价值。
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‘]; }
以上是关于laravel 配置设置的主要内容,如果未能解决你的问题,请参考以下文章