SettingsController   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
dl 0
loc 40
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A edit() 0 5 1
A __construct() 0 3 1
A show() 0 5 1
A save() 0 19 3
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use Carbon\Carbon;
7
use App\Setting;
8
use App\Http\Requests;
9
use App\Http\Controllers\Controller;
10
11
class SettingsController extends Controller
12
{
13
	public function __construct()
14
    {
15
        $this->middleware('auth');
16
    }
17
18
    public function show()
19
    {
20
    	$settings = \Utilities::getSettings();
21
22
    	return view('settings.show',compact('settings'));
23
    }
24
25
    public function edit()
26
    {
27
    	$settings = \Utilities::getSettings();
28
29
    	return view('settings.edit',compact('settings'));
30
    }
31
32
    public function save(Request $request)
33
    {
34
        // Get All Inputs Except '_Token' to loop through and save
35
        $settings = $request->except('_token');
36
37
        // Update All Settings
38
        foreach ($settings as $key => $value) {
39
40
            if ($key == "gym_logo") 
41
            {
42
                \Utilities::uploadFile($request,'', $key,'gym_logo',\constPaths::GymLogo); // Upload File
43
                $value = $key.'.jpg'; // Image Name For DB
44
            }
45
46
            Setting::where('key', '=',$key)->update(['value' => $value ]);
47
        }
48
       
49
        flash()->success('Setting was successfully updated');
50
        return redirect('settings/edit');
51
    }
52
53
}