Passed
Push — dev5a ( 720ced...bf2271 )
by Ron
07:37
created

SettingsController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 25
dl 0
loc 55
ccs 24
cts 28
cp 0.8571
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A settingsForm() 0 7 1
A submitEmailSettings() 0 5 1
A sendTestEmail() 0 6 1
A submitLogo() 0 6 1
A emailForm() 0 9 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
use App\Domains\Admin\SetEmailProperties;
12
13
use App\Http\Requests\Settings\NewLogoRequest;
14
use App\Http\Requests\Settings\EmailSettingsRequest;
15
use App\Http\Requests\Settings\GeneralSettingsRequest;
16
17
class SettingsController extends Controller
18
{
19 2
    public function settingsForm()
20
    {
21 2
        return view('settings.generalSettings', [
22 2
            'tz_list'  => \Timezonelist::toArray(),
23
            'settings' => [
24 2
                'timezone' => config('app.timezone'),
25 2
                'filesize' => config('filesystems.paths.max_size'),
26
            ],
27
        ]);
28
    }
29
30 2
    public function submitSettings(GeneralSettingsRequest $request)
31
    {
32 2
        (new SettingsDomain)->submitNewSettings($request);
33
34 2
        Log::notice('General Settings have been updated by '.Auth::user()->full_name.'.  Data - ', $request->toArray());
35 2
        return response()->json(['success' => true]);
36
    }
37
38 2
    public function submitLogo(NewLogoRequest $request)
39
    {
40 2
        $newPath = (new SettingsDomain)->saveNewLogo($request->file);
41
42 2
        Log::notice('New Logo uploaded by '.Auth::user()->full_name.'.  Details - ', ['Logo Path' => $newPath]);
43 2
        return response()->json(['url' => $newPath]);
44
    }
45
46 2
    public function emailForm()
47
    {
48 2
        return view('settings.emailSettings', [
49
            'current' => [
50 2
                'host'         => config('mail.host'),
51 2
                'port'         => config('mail.port'),
52 2
                'encryption'   => config('mail.encryption'),
53 2
                'username'     => config('mail.username'),
54 2
                'from_address' => config('mail.from.address'),
55
            ],
56
        ]);
57
    }
58
59
    public function sendTestEmail(EmailSettingsRequest $request)
60
    {
61
        $obj = new SetEmailProperties;
62
        $res = $obj->sendTestEmail($request, Auth::user()->email);
63
64
        return response()->json(['success' => $res]);
65
    }
66
67 2
    public function submitEmailSettings(EmailSettingsRequest $request)
68
    {
69 2
        (new SetEmailProperties)->saveEmailSettings($request);
70 2
        Log::notice('Email Settings have been modified by '.Auth::user()->full_name);
71 2
        return response()->json(['success' => true]);
72
    }
73
}
74