SettingsController::edit()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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
}