Passed
Push — dev5a ( 6555e1...720ced )
by Ron
07:58
created

SettingsController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 27
ccs 13
cts 13
cp 1
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A settingsForm() 0 7 1
A submitLogo() 0 6 1
A submitSettings() 0 6 1
1
<?php
2
3
namespace App\Http\Controllers\Admin;
4
5
use Illuminate\Support\Facades\Log;
6
use Illuminate\Support\Facades\Auth;
7
8
use App\Http\Controllers\Controller;
9
10
use App\Domains\Admin\SettingsDomain;
11
12
use App\Http\Requests\Settings\NewLogoRequest;
13
use App\Http\Requests\Settings\GeneralSettingsRequest;
14
15
class SettingsController extends Controller
16
{
17 2
    public function settingsForm()
18
    {
19 2
        return view('settings.generalSettings', [
20 2
            'tz_list'  => \Timezonelist::toArray(),
21
            'settings' => [
22 2
                'timezone' => config('app.timezone'),
23 2
                'filesize' => config('filesystems.paths.max_size'),
24
            ],
25
        ]);
26
    }
27
28 2
    public function submitSettings(GeneralSettingsRequest $request)
29
    {
30 2
        (new SettingsDomain)->submitNewSettings($request);
31
32 2
        Log::notice('General Settings have been updated by '.Auth::user()->full_name.'.  Data - ', $request->toArray());
33 2
        return response()->json(['success' => true]);
34
    }
35
36 2
    public function submitLogo(NewLogoRequest $request)
37
    {
38 2
        $newPath = (new SettingsDomain)->saveNewLogo($request->file);
39
40 2
        Log::notice('New Logo uploaded by '.Auth::user()->full_name.'.  Details - ', ['Logo Path' => $newPath]);
41 2
        return response()->json(['url' => $newPath]);
42
    }
43
}
44