Passed
Push — master ( 0378d7...bd60cc )
by
04:19
created

SettingController::saveHandler()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 3
nop 1
dl 0
loc 14
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Qsnh/meedu.
5
 *
6
 * (c) XiaoTeng <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace App\Http\Controllers\Backend;
13
14
use Illuminate\Http\Request;
15
use App\Http\Controllers\Controller;
16
17
class SettingController extends Controller
18
{
19
    public function index()
20
    {
21
        $config = config('meedu');
22
23
        return view('backend.setting.index', compact('config'));
24
    }
25
26
    public function saveHandler(Request $request)
27
    {
28
        $rows = [];
29
        foreach ($request->all() as $index => $item) {
30
            if (! preg_match('/\*/', $index)) {
31
                continue;
32
            }
33
            $index = str_replace('*', '.', $index);
34
            $rows[$index] = $item;
35
        }
36
        file_put_contents(config('meedu.save'), json_encode($rows));
37
        flash('修改成功', 'success');
38
39
        return back();
40
    }
41
}
42