ServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace NovaNavigaAdPreview;
4
5
use Illuminate\Support\Facades\Route;
6
use Laravel\Nova\Events\ServingNova;
7
use Laravel\Nova\Http\Middleware\Authenticate;
8
use Laravel\Nova\Nova;
9
use NovaNavigaAdPreview\Http\Middleware\Authorize;
10
11
class ServiceProvider extends \Illuminate\Support\ServiceProvider
12
{
13 2
    public function boot(): void
14
    {
15 2
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'nova-naviga-ad-preview');
16
17 2
        $this->app->booted(function () {
18 2
            $this->routes();
19 2
        });
20
21 2
        Nova::serving(function (ServingNova $event) {
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed. ( Ignorable by Annotation )

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

21
        Nova::serving(function (/** @scrutinizer ignore-unused */ ServingNova $event) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
            //
23 2
        });
24
    }
25
26
    /**
27
     * Register any application services.
28
     *
29
     * @return void
30
     */
31 2
    public function register()
32
    {
33
        //
34 2
    }
35
36 2
    protected function routes(): void
37
    {
38 2
        if ($this->app->routesAreCached()) {
39
            return;
40
        }
41
42
        // Load admin dashboard routes
43 2
        Nova::router(
44 2
            ['nova', Authenticate::class, Authorize::class],
45 2
            'nova-naviga-ad-preview'
46 2
        )
47 2
            ->group(__DIR__.'/../routes/inertia.php');
48
49
        // Load api routes
50 2
        Route::middleware(['nova', Authorize::class])
51 2
            ->prefix('nova-vendor/nova-naviga-ad-preview')
52 2
            ->group(__DIR__.'/../routes/api.php');
53
    }
54
}
55