vanhempi
commit
51be17eeba
1 muutettua tiedostoa jossa 57 lisäystä ja 15 poistoa
  1. 57
    15
      app/Filament/Resources/EsgResource.php

+ 57
- 15
app/Filament/Resources/EsgResource.php Näytä tiedosto

50
                             TextInput::make('title')
50
                             TextInput::make('title')
51
                             ->label("標題")
51
                             ->label("標題")
52
                             ->columnSpan(1)
52
                             ->columnSpan(1)
53
-                            ->required($locale == "zh_TW"),
53
+                            ->required($locale == "zh_TW")
54
+                            ->validationMessages([
55
+                                'required' => '請填寫標題',
56
+                            ])
54
                         ])->locales(["zh_TW", "en"])
57
                         ])->locales(["zh_TW", "en"])
55
                         ->columnSpanFull()->columns(3),
58
                         ->columnSpanFull()->columns(3),
56
                     ]),
59
                     ]),
58
                         FileUpload::make('banner_pc')->label("Banner (PC)")
61
                         FileUpload::make('banner_pc')->label("Banner (PC)")
59
                         ->disk("public")
62
                         ->disk("public")
60
                         // ->helperText('建議寬高限制為:1280*720px,檔案大小限制為1M以下')->maxSize('1024')
63
                         // ->helperText('建議寬高限制為:1280*720px,檔案大小限制為1M以下')->maxSize('1024')
61
-                        ->directory("esg")->required(),
64
+                        ->directory("esg")->required()
65
+                        ->validationMessages([
66
+                            'required' => '請上傳圖片',
67
+                        ]),
62
                         FileUpload::make('banner_mobile')->label("Banner (Mobile)")
68
                         FileUpload::make('banner_mobile')->label("Banner (Mobile)")
63
                         ->disk("public")
69
                         ->disk("public")
64
                         // ->helperText('建議寬高限制為:600*896px,檔案大小限制為1M以下')->maxSize('1024')
70
                         // ->helperText('建議寬高限制為:600*896px,檔案大小限制為1M以下')->maxSize('1024')
65
-                        ->directory("esg")->required(),
71
+                        ->directory("esg")->required()
72
+                        ->validationMessages([
73
+                            'required' => '請上傳圖片',
74
+                        ]),
66
                         Translate::make()->schema(fn (string $locale) => [
75
                         Translate::make()->schema(fn (string $locale) => [
67
                             TextInput::make('banner_alt')
76
                             TextInput::make('banner_alt')
68
                             ->label("Banner 圖片註釋")
77
                             ->label("Banner 圖片註釋")
69
-                            ->required($locale == "zh_TW"),
78
+                            ->required($locale == "zh_TW")
79
+                            ->validationMessages([
80
+                                'required' => '請填寫圖片註釋',
81
+                            ]),
70
                             Textarea::make("description")->rows(5)->columnSpanFull()->label("短文"),
82
                             Textarea::make("description")->rows(5)->columnSpanFull()->label("短文"),
71
                         ])->locales(["zh_TW", "en"])
83
                         ])->locales(["zh_TW", "en"])
72
                         ->columnSpanFull(),
84
                         ->columnSpanFull(),
95
                                     ->fileAttachmentsDirectory('attachments')
107
                                     ->fileAttachmentsDirectory('attachments')
96
                                     ->fileAttachmentsVisibility('private')
108
                                     ->fileAttachmentsVisibility('private')
97
                                     ->disableToolbarButtons(['attachFiles'])
109
                                     ->disableToolbarButtons(['attachFiles'])
98
-                                    ->required($locale == "zh_TW"),
110
+                                    ->required($locale == "zh_TW")
111
+                                    ->validationMessages([
112
+                                        'required' => '請填寫文字內容',
113
+                                    ]),
99
                                 ])
114
                                 ])
100
                                 ->locales(["zh_TW", "en"])
115
                                 ->locales(["zh_TW", "en"])
101
                                 ->id(fn ($get) => "para_text_" . $get('item_key')),
116
                                 ->id(fn ($get) => "para_text_" . $get('item_key')),
126
                                             //     ->visible(fn (Get $get) => in_array($get('block_type'), ['title', 'subtitle', 'highlight'])),
141
                                             //     ->visible(fn (Get $get) => in_array($get('block_type'), ['title', 'subtitle', 'highlight'])),
127
                                             RichEditor::make('block_content')
142
                                             RichEditor::make('block_content')
128
                                                 ->disableToolbarButtons(['attachFiles'])
143
                                                 ->disableToolbarButtons(['attachFiles'])
129
-                                                ->required($locale == "zh_TW"),
144
+                                                ->required($locale == "zh_TW")
145
+                                                ->validationMessages([
146
+                                                    'required' => '請填寫文字內容',
147
+                                                ]),
130
                                         ])
148
                                         ])
131
                                         ->locales(["zh_TW", "en"])
149
                                         ->locales(["zh_TW", "en"])
132
                                         ->id(fn ($get) => "text_block_" . $get('block_item_key')),
150
                                         ->id(fn ($get) => "text_block_" . $get('block_item_key')),
192
                                     Translate::make()->schema(fn (string $locale) => [
210
                                     Translate::make()->schema(fn (string $locale) => [
193
                                         Grid::make(2)  // 改用 Grid 來支援動態 columns
211
                                         Grid::make(2)  // 改用 Grid 來支援動態 columns
194
                                             ->schema([
212
                                             ->schema([
195
-                                                TextInput::make('content.head1')->label('標題第1欄')->required(),
213
+                                                TextInput::make('content.head1')->label('標題第1欄')->required()
214
+                                                ->validationMessages([
215
+                                                    'required' => '請填寫',
216
+                                                ]),
196
                                                 Radio::make('content.head_align1')
217
                                                 Radio::make('content.head_align1')
197
                                                     ->label('對齊')
218
                                                     ->label('對齊')
198
                                                     ->options([
219
                                                     ->options([
201
                                                         3 => '置右'
222
                                                         3 => '置右'
202
                                                     ])
223
                                                     ])
203
                                                     ->default(1),
224
                                                     ->default(1),
204
-                                                TextInput::make('content.head2')->label('標題第2欄')->required(),
225
+                                                TextInput::make('content.head2')->label('標題第2欄')->required()
226
+                                                ->validationMessages([
227
+                                                    'required' => '請填寫',
228
+                                                ]),
205
                                                 Radio::make('content.head_align2')
229
                                                 Radio::make('content.head_align2')
206
                                                     ->label('對齊')
230
                                                     ->label('對齊')
207
                                                     ->options([
231
                                                     ->options([
260
                                                         RichEditor::make('col1')
284
                                                         RichEditor::make('col1')
261
                                                             ->label('第1欄')
285
                                                             ->label('第1欄')
262
                                                             ->disableToolbarButtons(['attachFiles'])
286
                                                             ->disableToolbarButtons(['attachFiles'])
263
-                                                            ->required($locale == "zh_TW"),
287
+                                                            ->required($locale == "zh_TW")
288
+                                                            ->validationMessages([
289
+                                                                'required' => '請填寫',
290
+                                                            ]),
264
                                                         // TextInput::make('col2')->label('第2欄')->required(),
291
                                                         // TextInput::make('col2')->label('第2欄')->required(),
265
                                                         Radio::make('align2')
292
                                                         Radio::make('align2')
266
                                                             ->label('對齊')
293
                                                             ->label('對齊')
273
                                                         RichEditor::make('col2')
300
                                                         RichEditor::make('col2')
274
                                                             ->label('第2欄')
301
                                                             ->label('第2欄')
275
                                                             ->disableToolbarButtons(['attachFiles'])
302
                                                             ->disableToolbarButtons(['attachFiles'])
276
-                                                            ->required($locale == "zh_TW"),
303
+                                                            ->required($locale == "zh_TW")
304
+                                                            ->validationMessages([
305
+                                                                'required' => '請填寫',
306
+                                                            ]),
277
                                                         Radio::make('align3')
307
                                                         Radio::make('align3')
278
                                                             ->label('對齊')
308
                                                             ->label('對齊')
279
                                                             ->options([
309
                                                             ->options([
287
                                                             ->label('第3欄')
317
                                                             ->label('第3欄')
288
                                                             ->disableToolbarButtons(['attachFiles'])
318
                                                             ->disableToolbarButtons(['attachFiles'])
289
                                                             ->visible(fn (Get $get) => intval($get('../../../content.column_count')) >= 3)
319
                                                             ->visible(fn (Get $get) => intval($get('../../../content.column_count')) >= 3)
290
-                                                            ->required($locale == "zh_TW" && fn (Get $get)=> intval($get("../../../content.column_count")) >= 3),
320
+                                                            ->required($locale == "zh_TW" && fn (Get $get)=> intval($get("../../../content.column_count")) >= 3)
321
+                                                            ->validationMessages([
322
+                                                                'required' => '請填寫',
323
+                                                            ]),
291
                                                             Radio::make('align4')
324
                                                             Radio::make('align4')
292
                                                                 ->label('對齊')
325
                                                                 ->label('對齊')
293
                                                                 ->options([
326
                                                                 ->options([
301
                                                                 ->label('第4欄')
334
                                                                 ->label('第4欄')
302
                                                                 ->disableToolbarButtons(['attachFiles'])
335
                                                                 ->disableToolbarButtons(['attachFiles'])
303
                                                                 ->visible(fn (Get $get) => intval($get('../../../content.column_count')) >= 4)
336
                                                                 ->visible(fn (Get $get) => intval($get('../../../content.column_count')) >= 4)
304
-                                                                ->required($locale == "zh_TW" && fn (Get $get)=> intval($get("../../../content.column_count")) >= 4),
337
+                                                                ->required($locale == "zh_TW" && fn (Get $get)=> intval($get("../../../content.column_count")) >= 4)
338
+                                                                ->validationMessages([
339
+                                                                    'required' => '請填寫',
340
+                                                                ]),
305
                                                     ])
341
                                                     ])
306
                                                     ->reactive()  // 加入響應式
342
                                                     ->reactive()  // 加入響應式
307
                                             ])->locales(["zh_TW", "en"]),
343
                                             ])->locales(["zh_TW", "en"]),
325
                                             }),
361
                                             }),
326
                                         Translate::make()->schema(fn (string $locale) => [
362
                                         Translate::make()->schema(fn (string $locale) => [
327
                                             TextInput::make('image_alt')->label("圖片註文")
363
                                             TextInput::make('image_alt')->label("圖片註文")
328
-                                            ->required($locale == "zh_TW"),
329
                                         ])->locales(["zh_TW", "en"])
364
                                         ])->locales(["zh_TW", "en"])
330
                                         ->id(fn ($get) => "para_img_mul_" . $get('para_img_item_key')),
365
                                         ->id(fn ($get) => "para_img_mul_" . $get('para_img_item_key')),
331
                                         FileUpload::make('image_url')->label("")->disk("public")
366
                                         FileUpload::make('image_url')->label("")->disk("public")
332
                                         // ->helperText('建議寬高限制為:1080*675px,檔案大小限制為1M以下')->maxSize('1024')
367
                                         // ->helperText('建議寬高限制為:1080*675px,檔案大小限制為1M以下')->maxSize('1024')
333
                                         ->directory("esg/paragraphPhoto")
368
                                         ->directory("esg/paragraphPhoto")
334
-                                        ->maxFiles(10),
369
+                                        ->maxFiles(10)
370
+                                        ->required()
371
+                                        ->validationMessages([
372
+                                            'required' => '請上傳圖片',
373
+                                        ]),
335
                                     ])
374
                                     ])
336
                                     ->addActionLabel('新增')
375
                                     ->addActionLabel('新增')
337
                                     ->label("")
376
                                     ->label("")
344
                                     ->disk("public")
383
                                     ->disk("public")
345
                                     ->directory("esg/paragraphVideo")
384
                                     ->directory("esg/paragraphVideo")
346
                                     ->helperText('建議寬高限制為:2000*720px,出血寬度720px,主要圖像範圍為:1280*720px,檔案大小限制為1M以下')->maxSize('1024'),
385
                                     ->helperText('建議寬高限制為:2000*720px,出血寬度720px,主要圖像範圍為:1280*720px,檔案大小限制為1M以下')->maxSize('1024'),
347
-                                    TextInput::make('content.link')->label("網址")->required(),
386
+                                    TextInput::make('content.link')->label("網址")->required()
387
+                                    ->validationMessages([
388
+                                        'required' => '請附上連結',
389
+                                    ]),
348
                                     Translate::make()->schema(fn (string $locale) => [
390
                                     Translate::make()->schema(fn (string $locale) => [
349
                                         TextInput::make('content.video_alt')->label("影片註文"),
391
                                         TextInput::make('content.video_alt')->label("影片註文"),
350
                                     ])->locales(["zh_TW", "en"])
392
                                     ])->locales(["zh_TW", "en"])