码迷,mamicode.com
首页 > 其他好文 > 详细

laravel 配置设置

时间:2019-03-06 12:00:30      阅读:422      评论:0      收藏:0      [点我收藏+]

标签:code   Fix   getconf   ret   each   div   pen   .sh   ESS   

    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 配置设置

标签:code   Fix   getconf   ret   each   div   pen   .sh   ESS   

原文地址:https://www.cnblogs.com/sgm4231/p/10482305.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!