Test Failed
Push — master ( 54db62...a5394f )
by Terzi
06:48
created

AdminServiceProvider::routes()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 1
nop 0
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Providers;
4
5
use App\Http\Terranet\Administrator\Dashboard\BlankPanel;
6
use App\Http\Terranet\Administrator\Dashboard\DatabasePanel;
7
use App\Http\Terranet\Administrator\Dashboard\MembersPanel;
8
use Illuminate\Support\ServiceProvider;
9
use Pingpong\Menus\Menu;
10
use Pingpong\Menus\MenuBuilder;
11
use Pingpong\Menus\MenuItem;
12
use Terranet\Administrator\Architect;
13
use Terranet\Administrator\Contracts\Module\Navigable;
14
use Terranet\Administrator\Dashboard\Manager;
15
use Terranet\Administrator\Dashboard\Row;
16
use Terranet\Options\Manager as OptionsManager;
0 ignored issues
show
Bug introduced by
The type Terranet\Options\Manager 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...
17
18
class AdminServiceProvider extends ServiceProvider
19
{
20
    /**
21
     * Dashboard panels registration.
22
     *
23
     * @param Manager $dashboard
24
     * @return Manager
25
     */
26
    protected function dashboard(Manager $dashboard)
27
    {
28
        return $dashboard
29
            ->row(function (Row $row) {
30
                $row->panel(new BlankPanel)->setWidth(12);
31
            })
32
            ->row(function (Row $row) {
33
                $row->panel(new MembersPanel)->setWidth(6);
34
                $row->panel(new DatabasePanel)->setWidth(6);
35
            });
36
    }
37
38
    /**
39
     * @param Menu $navigation
40
     * @return Menu
41
     */
42
    protected function navigation(Menu $navigation)
43
    {
44
        $navigation->create(Navigable::MENU_SIDEBAR, function (MenuBuilder $sidebar) {
45
            // Dashboard
46
            $sidebar->route('scaffold.dashboard', trans('administrator::module.dashboard'), [], 1, [
0 ignored issues
show
Bug introduced by
The function trans was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

46
            $sidebar->route('scaffold.dashboard', /** @scrutinizer ignore-call */ trans('administrator::module.dashboard'), [], 1, [
Loading history...
47
                'id' => 'dashboard',
48
                'icon' => 'fa fa-home',
49
                'active' => str_is(request()->route()->getName(), 'scaffold.dashboard'),
0 ignored issues
show
Deprecated Code introduced by
The function str_is() has been deprecated: Str::is() should be used directly instead. Will be removed in Laravel 5.9. ( Ignorable by Annotation )

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

49
                'active' => /** @scrutinizer ignore-deprecated */ str_is(request()->route()->getName(), 'scaffold.dashboard'),

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
Bug introduced by
The function request was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

49
                'active' => str_is(/** @scrutinizer ignore-call */ request()->route()->getName(), 'scaffold.dashboard'),
Loading history...
50
            ]);
51
52
            // Create "resources" group
53
            $sidebar->dropdown(trans('administrator::module.groups.resources'), function (MenuItem $sub) {
0 ignored issues
show
Unused Code introduced by
The parameter $sub 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

53
            $sidebar->dropdown(trans('administrator::module.groups.resources'), function (/** @scrutinizer ignore-unused */ MenuItem $sub) {

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...
54
            }, 2, ['id' => 'groups', 'icon' => 'fa fa-qrcode']);
55
        });
56
57
        $navigation->create(Navigable::MENU_TOOLS, function (MenuBuilder $tools) {
58
            if (config('administrator.file_manager.enabled')) {
0 ignored issues
show
Bug introduced by
The function config was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

58
            if (/** @scrutinizer ignore-call */ config('administrator.file_manager.enabled')) {
Loading history...
59
                $tools->url(
60
                    route('scaffold.media'),
0 ignored issues
show
Bug introduced by
The function route was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

60
                    /** @scrutinizer ignore-call */ 
61
                    route('scaffold.media'),
Loading history...
61
                    trans('administrator::buttons.media'),
0 ignored issues
show
Bug introduced by
The function trans was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

61
                    /** @scrutinizer ignore-call */ 
62
                    trans('administrator::buttons.media'),
Loading history...
62
                    1,
63
                    ['icon' => 'fa fa-file-text-o']
64
                );
65
            }
66
67
            if (config('administrator.settings.enabled') && class_exists(OptionsManager::class, true)) {
68
                $tools->url(
69
                    route('scaffold.settings.edit'),
70
                    trans('administrator::module.resources.settings'),
71
                    2,
72
                    ['icon' => 'fa fa-gears']
73
                );
74
            }
75
76
            if (config('administrator.translations.enabled')) {
77
                $tools->url(
78
                    route('scaffold.translations.index'),
79
                    trans('administrator::buttons.translations'),
80
                    3,
81
                    ['icon' => 'fa fa-globe']
82
                );
83
            }
84
85
            $tools->url(
86
                route('scaffold.logout'),
87
                trans('administrator::buttons.logout'),
88
                100,
89
                ['icon' => 'fa fa-mail-forward']
90
            );
91
        });
92
93
        return $navigation;
94
    }
95
96
    /**
97
     * Register services.
98
     *
99
     * @return void
100
     */
101
    public function register()
102
    {
103
        $this->app->singleton('scaffold.dashboard', function () {
104
            return $this->dashboard(new Manager());
105
        });
106
107
        $this->app->singleton('scaffold.navigation', function ($app) {
108
            return $this->navigation(new Menu($app['view'], $app['config']));
109
        });
110
    }
111
112
    /**
113
     * Bootstrap any application services.
114
     *
115
     * @return void
116
     */
117
    public function boot()
118
    {
119
        $this->routes();
120
    }
121
122
    /**
123
     * Register AdminArchitect routes.
124
     */
125
    protected function routes()
126
    {
127
        Architect::routes()
128
            ->withAuthenticationRoutes()
129
            ->withTranslationRoutes()
130
            ->withMediaRoutes()
131
            ->withSettingRoutes()
132
            ->withExtraRoutes(function () {
133
                if (file_exists($path = base_path('routes/admin.php'))) {
0 ignored issues
show
Bug introduced by
The function base_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

133
                if (file_exists($path = /** @scrutinizer ignore-call */ base_path('routes/admin.php'))) {
Loading history...
134
                    $this->loadRoutesFrom($path);
135
                }
136
            });
137
    }
138
}
139