1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BBSLab\NovaTranslation\Resources; |
4
|
|
|
|
5
|
|
|
use BBSLab\NovaTranslation\Fields\Translation; |
6
|
|
|
use BBSLab\NovaTranslation\Models\Label as Model; |
7
|
|
|
use BBSLab\NovaTranslation\NovaTranslationServiceProvider; |
8
|
|
|
use Illuminate\Http\Request; |
9
|
|
|
use Laravel\Nova\Fields\ID; |
10
|
|
|
use Laravel\Nova\Fields\Select; |
11
|
|
|
use Laravel\Nova\Fields\Text; |
12
|
|
|
use Laravel\Nova\Fields\Textarea; |
13
|
|
|
use Laravel\Nova\Resource; |
14
|
|
|
|
15
|
|
|
class Label extends TranslatableResource |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* The model the resource corresponds to. |
19
|
|
|
* |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
public static $model = 'BBSLab\\NovaTranslation\\Models\\Label'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
|
|
public static $title = 'key'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* {@inheritdoc} |
31
|
|
|
*/ |
32
|
|
|
public static $search = [ |
33
|
|
|
'key', |
34
|
|
|
'value', |
35
|
|
|
]; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* {@inheritdoc} |
39
|
|
|
*/ |
40
|
|
|
public static $group = null; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* {@inheritdoc} |
44
|
|
|
*/ |
45
|
|
|
public static function label() |
46
|
|
|
{ |
47
|
|
|
return trans(NovaTranslationServiceProvider::PACKAGE_ID.'::lang.labels.resources'); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* {@inheritdoc} |
52
|
|
|
*/ |
53
|
|
|
public static function singularLabel() |
54
|
|
|
{ |
55
|
|
|
return trans(NovaTranslationServiceProvider::PACKAGE_ID.'::lang.labels.resource'); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* {@inheritdoc} |
60
|
|
|
*/ |
61
|
|
|
public function fields(Request $request) |
62
|
|
|
{ |
63
|
|
|
return [ |
64
|
|
|
ID::make()->sortable(), |
65
|
|
|
|
66
|
|
|
Translation::make(), |
67
|
|
|
|
68
|
|
|
Select::make(trans(NovaTranslationServiceProvider::PACKAGE_ID.'::lang.labels.type'), 'type') |
69
|
|
|
->sortable() |
70
|
|
|
->options([ |
71
|
|
|
Model::TYPE_TEXT => trans(NovaTranslationServiceProvider::PACKAGE_ID.'::lang.labels.types.'.Model::TYPE_TEXT), |
72
|
|
|
Model::TYPE_UPLOAD => trans(NovaTranslationServiceProvider::PACKAGE_ID.'::lang.labels.types.'.Model::TYPE_UPLOAD), |
73
|
|
|
]) |
74
|
|
|
->displayUsingLabels(), |
75
|
|
|
|
76
|
|
|
Text::make(trans(NovaTranslationServiceProvider::PACKAGE_ID.'::lang.labels.key'), 'key') |
77
|
|
|
->sortable() |
78
|
|
|
->rules('required'), |
79
|
|
|
|
80
|
|
|
Textarea::make(trans(NovaTranslationServiceProvider::PACKAGE_ID.'::lang.labels.value'), 'value') |
81
|
|
|
->hideFromIndex(), |
82
|
|
|
]; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* {@inheritdoc} |
87
|
|
|
*/ |
88
|
|
|
public function cards(Request $request) |
89
|
|
|
{ |
90
|
|
|
return []; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* {@inheritdoc} |
95
|
|
|
*/ |
96
|
|
|
public function filters(Request $request) |
97
|
|
|
{ |
98
|
|
|
return []; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* {@inheritdoc} |
103
|
|
|
*/ |
104
|
|
|
public function lenses(Request $request) |
105
|
|
|
{ |
106
|
|
|
return []; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* {@inheritdoc} |
111
|
|
|
*/ |
112
|
|
|
public function actions(Request $request) |
113
|
|
|
{ |
114
|
|
|
return []; |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|