NLFileManager::menu()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
ccs 6
cts 6
cp 1
crap 3
rs 10
1
<?php
2
namespace ThinkOne\NovaLaravelFilemanager;
3
4
use Illuminate\Http\Request;
5
use Laravel\Nova\Menu\MenuSection;
6
use Laravel\Nova\Nova;
7
use Laravel\Nova\Tool;
8
use ThinkOne\NovaLaravelFilemanager\Helpers\Url;
9
use ThinkOne\NovaLaravelFilemanager\Traits\Menuable;
10
11
class NLFileManager extends Tool
12
{
13
    use Menuable;
14
15
    /**
16
     * Perform any tasks that need to happen when the tool is booted.
17
     *
18
     * @return void
19
     */
20 2
    public function boot()
21
    {
22 2
        Nova::script('nova-laravel-filemanager-tool', __DIR__.'/../dist/js/tool.js');
23 2
        Nova::style('nova-laravel-filemanager-tool', __DIR__.'/../dist/css/tool.css');
24
25 2
        Nova::provideToScript([
26 2
            'novaLaravelFileManager' => [
27 2
                'url'   => Url::addOrUpdateArgs($this->lfmUrl, 'type', '_TYPE_'),
28 2
                'types' => array_values(array_filter([
29 2
                    $this->displayImages?'Images':null,
30 2
                    $this->displayFiles?'Files':null,
31 2
                ])),
32 2
            ],
33 2
        ]);
34
    }
35
36
    /**
37
     * Build the menu that renders the navigation links for the tool.
38
     *
39
     * @param  \Illuminate\Http\Request $request
40
     * @return mixed
41
     */
42 1
    public function menu(Request $request)
43
    {
44 1
        if ($this->hideMenu) {
45 1
            return null;
46
        }
47
48 1
        return MenuSection::make($this->title ?: 'Files Manager')
49 1
            ->path('/nova-laravel-filemanager')
50 1
            ->icon($this->icon);
51
    }
52
}
53