Andrew 2 mēnešus atpakaļ
vecāks
revīzija
63dd3891f6
1 mainītis faili ar 23 papildinājumiem un 13 dzēšanām
  1. 23
    13
      app/Filament/Resources/BannerResource.php

+ 23
- 13
app/Filament/Resources/BannerResource.php Parādīt failu

@@ -49,34 +49,44 @@ class BannerResource extends Resource
49 49
                 //
50 50
                 Section::make('')->schema([
51 51
                     Group::make()->schema([
52
-                        Translate::make()->schema(fn (string $locale) => [
53
-                            Textarea::make('title')->required($locale == 'zh_TW')->label('大字標題'),
54
-                            Textarea::make('content')->required($locale == 'zh_TW')->label('小字標題'),
52
+                        Radio::make('type')->label('')->default(1)->options([1 => '圖片', 2 => '影片'])->reactive(),
53
+                        Translate::make()->schema(fn(string $locale) => [
54
+                            Textarea::make('title')
55
+                                ->required(fn($get) => $locale == 'zh_TW' && $get('../../type') == 1)
56
+                                ->label('大字標題'),
57
+                            Textarea::make('content')
58
+                                ->required(fn($get) => $locale == 'zh_TW' && $get('../../type') == 1)
59
+                                ->label('小字標題'),
55 60
                         ])
56 61
                             ->locales(['zh_TW', 'en'])
57 62
                             ->actions([
58 63
                                 app(DeepLService::class)->createTranslationAction('Main', ['title', 'content']),
59 64
                             ])->columnSpanFull(),
60
-                        Radio::make('type')->label('')->default(1)->options([1 => '圖片', 2 => '影片'])->reactive(),
61 65
                         Group::make()->schema([
62 66
                             FileUpload::make('img_url')->label('圖片')->directory('banners')->columnSpan(1)
63
-                                ->acceptedFileTypes(['image/jpeg', 'image/jpg', 'image/png', 'image/webp'])->required(fn ($get) => $get('type') == 1)->imageEditor()
64
-                                ->visible(fn ($get) => $get('type') == 1),
67
+                                ->acceptedFileTypes(['image/jpeg', 'image/jpg', 'image/png', 'image/webp'])
68
+                                ->required(fn($get) => $get('type') == 1)
69
+                                ->imageEditor()
70
+                                ->visible(fn($get) => $get('type') == 1),
65 71
                             FileUpload::make('mobile_img')->label('手機板圖片')->directory('banners')->columnSpan(1)
66
-                                ->acceptedFileTypes(['image/jpeg', 'image/jpg', 'image/png', 'image/webp'])->required(fn ($get) => $get('type') == 1)->imageEditor()
67
-                                ->visible(fn ($get) => $get('type') == 1),
68
-                            Translate::make()->schema(fn (string $locale) => [
69
-                                TextInput::make('img_alt')->required(fn ($get) => $locale == 'zh_TW' && $get('../../type') == 1)->label('圖片註釋'),
72
+                                ->acceptedFileTypes(['image/jpeg', 'image/jpg', 'image/png', 'image/webp'])
73
+                                ->required(fn($get) => $get('type') == 1)
74
+                                ->imageEditor()
75
+                                ->visible(fn($get) => $get('type') == 1),
76
+                            Translate::make()->schema(fn(string $locale) => [
77
+                                TextInput::make('img_alt')
78
+                                    ->required(fn($get) => $locale == 'zh_TW' && $get('../../type') == 1)
79
+                                    ->label('圖片註釋'),
70 80
                             ])
71 81
                                 ->locales(['zh_TW', 'en'])
72 82
                                 ->actions([
73 83
                                     app(DeepLService::class)->createTranslationAction('Main', ['img_alt']),
74 84
                                 ])->columnSpan(1)
75
-                                ->visible(fn ($get) => $get('../type') == 1),
85
+                                ->visible(fn($get) => $get('../type') == 1),
76 86
                         ])->columnSpanFull(),
77 87
                         TextInput::make('video_url')->label('影片網址')->url()->columnSpanFull()
78
-                            ->required(fn ($get) => $get('type') == 2)
79
-                            ->visible(fn ($get) => $get('type') == 2),
88
+                            ->required(fn($get) => $get('type') == 2)
89
+                            ->visible(fn($get) => $get('type') == 2),
80 90
                         Radio::make('visible')->label('顯示/不顯示')->options([1 => '顯示', 0 => '不顯示'])->inline()->default(1)->columnSpan(2),
81 91
                     ])->columns(4)->columnSpanFull(),
82 92
                 ]),