Passed
Push — main ( ac25fd...00e2bd )
by Yaroslav
14:14
created

ExportStoredFile::actions()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 12
ccs 0
cts 8
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace NovaExportConfiguration\Nova\Resources;
4
5
use Laravel\Nova\Fields\DateTime;
6
use Laravel\Nova\Fields\ID;
7
use Laravel\Nova\Fields\Text;
8
use Laravel\Nova\Http\Requests\NovaRequest;
9
use Laravel\Nova\Resource;
10
use NovaExportConfiguration\Nova\Actions\CustomFileExports;
11
use NovaExportConfiguration\NovaExportConfig;
12
13
class ExportStoredFile extends Resource
14
{
15
    public static $model = \NovaExportConfiguration\Models\ExportStoredFile::class;
16
17
    public static $title = 'name';
18
19
    public static $group = 'Export';
20
21
    public static $search = [
22
        'name',
23
    ];
24
25
    public static function label()
26
    {
27
        return __('Exported Files');
28
    }
29
30
    public function fields(NovaRequest $request)
31
    {
32
        return [
33
            ID::make(__('ID'), 'id')
34
              ->hideFromIndex()
35
              ->sortable(),
36
37
            Text::make(__('File Name'), 'name')
38
                ->sortable()
39
                ->showOnDetail()
40
                ->showOnIndex(),
41
42
            Text::make(__('Type'), 'disk')
43
                ->exceptOnForms(),
44
45
            DateTime::make(__('Created At'), 'created_at')
46
                    ->sortable(),
47
48
            Text::make(__('Download Link'), function () {
49
                return view('nova-export-configuration::link', [
50
                    'path' => $this->path,
0 ignored issues
show
Bug Best Practice introduced by
The property path does not exist on NovaExportConfiguration\...ources\ExportStoredFile. Since you implemented __get, consider adding a @property annotation.
Loading history...
51
                ])->render();
52
            })->asHtml()->hideWhenCreating()->hideWhenUpdating(),
53
        ];
54
    }
55
56
    public function actions(NovaRequest $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request 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

56
    public function actions(/** @scrutinizer ignore-unused */ NovaRequest $request)

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...
57
    {
58
        $actions = [];
59
60
        if(!empty($exportsList = NovaExportConfig::customExportsOptions())) {
61
            $actions[] = CustomFileExports::make()
62
                ->exportsList($exportsList)
63
                ->askForFilename()
64
                ->askForWriterType();
65
        }
66
67
        return $actions;
68
    }
69
}
70