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

SettingsDomain::submitNewSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Domains\Admin;
4
5
use Illuminate\Http\UploadedFile;
6
use Illuminate\Support\Facades\Log;
7
8
use App\Settings;
9
10
use App\Domains\FilesDomain;
11
12
class SettingsDomain
13
{
14
    //  Update the Settings table in the database for a new system setting.
15 16
    public function updateSettings($key, $value)
16
    {
17 16
        Settings::firstOrCreate(
18 16
            ['key' => $key],
19 16
            ['key' => $key, 'value' => $value]
20 16
        )->update(['value' => $value]);
21
22 16
        return true;
23
    }
24
25 4
    public function submitNewSettings($request)
26
    {
27 4
        $this->updateSettings('app.timezone', $request->timezone);
28 4
        $this->updateSettings('filesystems.paths.max_size', $request->filesize);
29
30 4
        return true;
31
    }
32
33
    //  Save a new application logo
34 4
    public function saveNewLogo(UploadedFile $file)
35
    {
36 4
        $logoName = (new FilesDomain('images/logo', 'public'))->saveFile($file);
37 4
        $logoPath = config('filesystems.disks.public.url').'/images/logo/';
38 4
        $this->updateSettings('app.logo', $logoPath.$logoName);
39
40 4
        return $logoPath.$logoName;
41
    }
42
}
43