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> |
|
|
|
|
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, |
|
|
|
|
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) |
|
|
|
|
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
|
|
|
|