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, |
|
|
|
|
51
|
|
|
])->render(); |
52
|
|
|
})->asHtml()->hideWhenCreating()->hideWhenUpdating(), |
53
|
|
|
]; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function actions(NovaRequest $request) |
|
|
|
|
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
|
|
|
|