Passed
Push — dev5a ( 9eb7a1...6555e1 )
by Ron
07:16
created

SettingsDomain   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 21
ccs 11
cts 11
cp 1
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A saveNewLogo() 0 7 1
A updateSettings() 0 8 1
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 12
    public function updateSettings($key, $value)
16
    {
17 12
        Settings::firstOrCreate(
18 12
            ['key' => $key],
19 12
            ['key' => $key, 'value' => $value]
20 12
        )->update(['value' => $value]);
21
22 12
        return true;
23
    }
24
25
    //  Save a new application logo
26 4
    public function saveNewLogo(UploadedFile $file)
27
    {
28 4
        $logoName = (new FilesDomain('images/logo', 'public'))->saveFile($file);
29 4
        $logoPath = config('filesystems.disks.public.url').'/images/logo/';
30 4
        $this->updateSettings('app.logo', $logoPath.$logoName);
31
32 4
        return $logoPath.$logoName;
33
    }
34
}
35