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

SettingsController::sendTestEmail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
ccs 0
cts 4
cp 0
crap 2
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
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