ExportStoredFile::fields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 22
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 27
ccs 22
cts 22
cp 1
rs 9.6
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace NovaResourceDynamicExport\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 NovaResourceDynamicExport\CustomResourcesExport;
11
use NovaResourceDynamicExport\Nova\Actions\CustomFileExports;
12
use ThinkStudio\HtmlField\Html;
13
14
/**
15
 * @extends Resource<\NovaResourceDynamicExport\Models\ExportStoredFile>
16
 */
17
class ExportStoredFile extends Resource
18
{
19
    /**
20
     * The model the resource corresponds to.
21
     *
22
     * @var class-string<\NovaResourceDynamicExport\Models\ExportStoredFile>
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<\NovaResour...odels\ExportStoredFile> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<\NovaResourceDynamicExport\Models\ExportStoredFile>.
Loading history...
23
     */
24
    public static $model = \NovaResourceDynamicExport\Models\ExportStoredFile::class;
25
26
    public static $title = 'name';
27
28
    public static $group = 'Export';
29
30
    public static $search = [
31
        'name',
32
    ];
33
34 1
    public static function label()
35
    {
36 1
        return __('Exported Files');
37
    }
38
39 1
    public function fields(NovaRequest $request)
40
    {
41 1
        return [
42 1
            ID::make(__('ID'), 'id')
43 1
                ->hideFromIndex()
44 1
                ->sortable(),
45
46 1
            Text::make(__('File Name'), 'name')
47 1
                ->sortable()
48 1
                ->showOnDetail()
49 1
                ->showOnIndex(),
50
51 1
            Text::make(__('Type'), 'disk')
52 1
                ->exceptOnForms(),
53
54 1
            DateTime::make(__('Created At'), 'created_at')
55 1
                ->sortable(),
56
57 1
            Html::make(__('Download Link'), function () {
58 1
                return view('nova-html-field::blocks.link', [
59 1
                    'href' => $this->download_link,
0 ignored issues
show
Bug Best Practice introduced by
The property download_link does not exist on NovaResourceDynamicExpor...ources\ExportStoredFile. Since you implemented __get, consider adding a @property annotation.
Loading history...
60 1
                ])->render();
61 1
            })
62 1
                ->clickable()
63 1
                ->hideWhenCreating()
64 1
                ->showOnIndex()
65 1
                ->showOnPreview(),
66 1
        ];
67
    }
68
69 3
    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

69
    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...
70
    {
71 3
        $actions = [];
72
73 3
        if (!empty($exportsList = CustomResourcesExport::options())) {
74 3
            $actions[] = CustomFileExports::make()
75 3
                ->exportsList($exportsList)
76 3
                ->askForFilename()
77 3
                ->askForWriterType();
78
        }
79
80 3
        return $actions;
81
    }
82
}
83