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

SettingsDomain::updateSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
nc 1
nop 2
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 1
rs 10
c 1
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 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