Test Failed
Push — dev6 ( e3f62b...d58043 )
by Ron
17:13
created

HandleInertiaRequests::share()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 3

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 14
c 3
b 0
f 0
dl 0
loc 24
rs 9.7998
ccs 12
cts 12
cp 1
cc 3
nc 1
nop 1
crap 3
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use App\Actions\General\BuildNavbar;
0 ignored issues
show
Bug introduced by
The type App\Actions\General\BuildNavbar was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Http\Request;
7
use Inertia\Middleware;
8
use PragmaRX\Version\Package\Version;
9
10
class HandleInertiaRequests extends Middleware
11
{
12
    /**
13
     * The root template that's loaded on the first page visit.
14
     */
15
    protected $rootView = 'app';
16
17
    /**
18
     * Determines the current asset version.
19
     */
20 28
    public function version(Request $request)
21
    {
22 28
        return parent::version($request);
23
    }
24
25
    /**
26
     * Defines the props that are shared by default.
27
     */
28 198
    public function share(Request $request)
29
    {
30 198
        return array_merge(parent::share($request), [
31
            //  Flash messages are used for success/failure messages on next page load
32
            'flash' => [
33 198
                'message' => fn() => $request->session()->get('message'),
34 198
                'type'    => fn() => $request->session()->get('type'),
35
            ],
36
            //  App information that is shared and used on all pages
37
            'app' => [
38 198
                'name'    => config('app.name'),
39 198
                'logo'    => config('app.logo'),
40 198
                'version' => (new Version)->full(),
41
                //  Current logged in user
42
                'user'   => fn() => $request->user() ? $request->user() : null,
43 198
                //  File information
44
                'fileData' => [
45 198
                    'maxSize'   => config('filesystems.max_filesize'),
46
                    'chunkSize' => config('filesystems.chunk_size'),
47
                    'token'     => csrf_token(),
48 198
                ],
49 198
            ],
50 198
            //  Dynamically built navigation menu
51
            'navBar' => fn() => $request->user() ? (new BuildNavbar)->build($request->user()) : [],
52
        ]);
53
    }
54
}
55