Completed
Pull Request — develop (#57)
by Tony
07:24
created

SettingsController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 2
Metric Value
c 4
b 1
f 2
dl 0
loc 7
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/*
3
 * Copyright (C) 2016 Tony Murray <[email protected]>
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation, either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 */
17
/**
18
 * SettingsController.php
19
 *
20
 * @package    LibreNMS
21
 * @author     Tony Murray <[email protected]>
22
 * @copyright  2016 Tony Murray
23
 * @license    @license http://opensource.org/licenses/GPL-3.0 GNU Public License v3 or later
24
 */
25
26
namespace App\Http\Controllers;
27
28
use App\Http\Requests;
29
use App\Models\DbConfig;
30
use Illuminate\Http\Request;
31
use Input;
32
use Settings;
33
34
class SettingsController extends Controller
35
{
36
    /**
37
     * Constructor
38
     */
39
    public function __construct(Request $request)
1 ignored issue
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
    {
41
        $this->middleware('auth');
42
    }
43
44
    /**
45
     * Display a listing of the resource.
46
     *
47
     * @return \Illuminate\Http\Response
48
     */
49
    public function index()
50
    {
51
//        $settings = Settings::all();
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
52
        $settings = Settings::get('snmp');
53
54
        return view('settings.list', ['settings' => $settings]);
55
    }
56
57
    /**
58
     * Show the form for creating a new resource.
59
     *
60
     * @return \Illuminate\Http\Response
61
     */
62
    public function create()
63
    {
64
        //
65
    }
66
67
    /**
68
     * Store a newly created resource in storage.
69
     *
70
     * @param  \Illuminate\Http\Request $request
71
     * @return \Illuminate\Http\Response
72
     */
73
    public function store(Request $request)
1 ignored issue
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
74
    {
75
        $type = Input::get('type');
76
        if ($type == 'settings-value' || $type == 'settings-array') {
77
            Settings::set(Input::get('key'), Input::get('value'));
78
            return response('OK', 200);
79
        }
80
        return response('Invalid Data', 422);
81
    }
82
83
    /**
84
     * Display the specified resource.
85
     *
86
     * @param  int $id
87
     * @return \Illuminate\Http\Response
88
     */
89
    public function show($id)
90
    {
91
        return view('settings.list', ['section' => $id]);
92
    }
93
94
    /**
95
     * Show the form for editing the specified resource.
96
     *
97
     * @param  int $id
98
     * @return \Illuminate\Http\Response
99
     */
100
    public function edit($id)
101
    {
102
        return view('settings.list', ['section' => $id]);
103
    }
104
105
    /**
106
     * Update the specified resource in storage.
107
     *
108
     * @param  \Illuminate\Http\Request $request
109
     * @param  int $id
110
     * @return \Illuminate\Http\Response
111
     */
112
    public function update(Request $request, $id)
2 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
113
    {
114
        //
115
    }
116
117
    /**
118
     * Remove the specified resource from storage.
119
     *
120
     * @param  int $id
121
     * @return \Illuminate\Http\Response
122
     */
123
    public function destroy($id)
124
    {
125
        Settings::forget($id);
126
    }
127
}
128