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

SettingsController::settingsForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 1
rs 10
c 0
b 0
f 0
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