SystemSettingController   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
c 3
b 0
f 0
lcom 0
cbo 5
dl 0
loc 49
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A index() 0 6 1
A update() 0 22 3
1
<?php namespace WITR\Http\Controllers\Admin;
2
3
use WITR\Http\Requests;
4
use WITR\Http\Controllers\Controller;
5
use WITR\SystemSetting;
6
7
use Illuminate\Http\Request;
8
9
class SystemSettingController extends Controller {
10
11
	public function __construct()
12
	{
13
		$this->middleware('auth');
14
		$this->middleware('admin');
15
	}
16
	
17
	/**
18
	 * Display a listing of the resource.
19
	 *
20
	 * @return Response
21
	 */
22
	public function index()
23
	{
24
		$settings = SystemSetting::all();
25
		return view('admin.settings.index')
26
			->withSettings($settings);
27
	}
28
29
	/**
30
	 * Update the specified resource in storage.
31
	 *
32
	 * @param  int  $id
0 ignored issues
show
Bug introduced by
There is no parameter named $id. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
33
	 * @return Response
34
	 */
35
	public function update(Request $request)
36
	{
37
		$input = $request->all();
38
		$settings = SystemSetting::all();
39
40
		foreach ($settings as $setting) {
41
			$value = $input['value_' . $setting->id];
42
			$setting->value = $value;
43
44
            $enabled_id = 'enabled_' . $setting->id;
45
            if (array_key_exists($enabled_id, $input)) {
46
                $setting->enabled = $input[$enabled_id];
47
            } else {
48
                $setting->enabled = 1;
49
            }
50
51
			$setting->save();
52
		}
53
54
		return redirect()->route('admin.settings')
55
			->with('success', 'Settings Saved!');
56
	}
57
}
58