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