Passed
Push — dev6 ( 5ebf7f...1a3248 )
by Ron
16:55
created

SetLogoController::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 17
rs 9.9332
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Http\Controllers\Admin\Logo;
4
5
use App\Events\Admin\NewLogoUploadedEvent;
6
use App\Http\Controllers\Controller;
7
use App\Http\Requests\Home\UploadImageRequest;
8
use App\Models\AppSettings;
9
use Illuminate\Support\Facades\Storage;
10
use Illuminate\Http\File;
11
12
class SetLogoController extends Controller
13
{
14
    /**
15
     * Save a new Application Logo
16
     */
17
    public function __invoke(UploadImageRequest $request)
18
    {
19
        $this->authorize('viewAny', AppSettings::class);
20
21
        //  Storage Path
22
        $path     = 'images/logo';
23
        $location = '/storage/'.Storage::disk('public')->putFile($path, new File($request->file));
0 ignored issues
show
Bug introduced by
Are you sure Illuminate\Support\Facad...p\File($request->file)) of type false|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

23
        $location = '/storage/'./** @scrutinizer ignore-type */ Storage::disk('public')->putFile($path, new File($request->file));
Loading history...
24
25
        AppSettings::firstOrCreate(
26
            ['key' => 'app.logo'],
27
            ['key' => 'app.logo', 'value' => $location]
28
        )->update([
29
            'value' => $location
30
        ]);
31
32
        event(new NewLogoUploadedEvent($location));
33
        return response()->noContent();
34
    }
35
}
36