Browse Source

260402 最新消息-雙語系影片欄位

OMEGA\lulufj.ho 4 days ago
parent
commit
5d85cd6631

+ 29
- 26
app/Filament/Resources/NewsResource.php View File

@@ -209,7 +209,7 @@ class NewsResource extends Resource
209 209
                                 ->label("")
210 210
                                 ->orderColumn('order')
211 211
                             ])
212
-                        ])->visible(fn (Get $get):bool => $get("paragraph_type") == 1),
212
+                        ])->visible(fn (Get $get):bool => $get("paragraph_type") == 1),//
213 213
                         Group::make()->schema([
214 214
                             FilamentLexicalEditor::make('text_content_tw')
215 215
                                 // ->label('繁體中文內容')
@@ -240,33 +240,36 @@ class NewsResource extends Resource
240 240
                                 ])
241 241
                                 ->columnSpanFull(),
242 242
                         ])->visible(fn (Get $get):bool => $get("paragraph_type") == 2),
243
-                            Group::make()->schema([
244
-                                Section::make("")->schema([
245
-                                    FileUpload::make('video_img')->label("影片底圖")
246
-                                    ->disk("public")
247
-                                    ->helperText('檔案大小限制為1MB以下')
248
-                                    ->directory("news/paragraph/video"),
249
-                                    // ->helperText('建議寬高限制為:2000*720px,出血寬度720px,主要圖像範圍為:1280*720px,檔案大小限制為1M以下')->maxSize('1024'),
243
+                        Group::make()->schema([
244
+                            Section::make("")->schema([
245
+                                FileUpload::make('video_img')->label("影片底圖")
246
+                                ->disk("public")
247
+                                ->helperText('檔案大小限制為1MB以下')
248
+                                ->directory("news/paragraph/video"),
249
+                                // ->helperText('建議寬高限制為:2000*720px,出血寬度720px,主要圖像範圍為:1280*720px,檔案大小限制為1M以下')->maxSize('1024'),
250
+                                Translate::make()->schema(fn (string $locale) => [
251
+                                    TextInput::make('video_img_alt')->label("圖片註文")->columnSpan(1),
252
+                                ])->locales(["zh_TW", "en"])
253
+                                ->id(fn ($get) => "para_video_img_alt_" . $get('item_key')),
254
+                                Radio::make("video_type")->label("")->options([
255
+                                    1 => "網址",
256
+                                    2 => "檔案"
257
+                                ])->columnSpanFull()->default(1)->Live(),
258
+                                Group::make()->schema([
250 259
                                     Translate::make()->schema(fn (string $locale) => [
251
-                                        TextInput::make('video_img_alt')->label("圖片註文")->columnSpan(1),
260
+                                        TextInput::make('link')->label("網址")->nullable()->columnSpan(1)
252 261
                                     ])->locales(["zh_TW", "en"])
253
-                                    ->id(fn ($get) => "para_video_img_alt_" . $get('item_key')),
254
-                                    Radio::make("video_type")->label("")->options([
255
-                                        1 => "網址",
256
-                                        2 => "檔案"
257
-                                    ])->columnSpanFull()->default(1)->Live(),
258
-                                    Group::make()->schema([
259
-                                        TextInput::make('link')->label("網址")->nullable(),
260
-                                    ])->visible(fn (Get $get):bool => $get("video_type") == 1)->columnSpanFull(),
261
-                                    Group::make()->schema([
262
-                                        FileUpload::make('video_url')->label("")->disk("public")->directory("news/paragraph/video")
263
-                                        ->helperText('檔案大小限制為100MB以下')
264
-                                        // ->helperText('建議影片寬高限制為:1920*1080px,出血寬度720px,大小限制為:100M以下')
265
-                                        // ->maxSize(102400)
266
-                                        ->nullable(),
267
-                                    ])->visible(fn (Get $get):bool => $get("video_type") == 2)->columnSpanFull(),
268
-                                ]),
269
-                            ])->visible(fn (Get $get):bool => $get("paragraph_type") == 3),
262
+                                    ->id(fn ($get) => "para_link_" . $get('item_key')),
263
+                                ])->visible(fn (Get $get):bool => $get("video_type") == 1)->columnSpanFull(),
264
+                                Group::make()->schema([
265
+                                    FileUpload::make('video_url')->label("")->disk("public")->directory("news/paragraph/video")
266
+                                    ->helperText('檔案大小限制為100MB以下')
267
+                                    // ->helperText('建議影片寬高限制為:1920*1080px,出血寬度720px,大小限制為:100M以下')
268
+                                    // ->maxSize(102400)
269
+                                    ->nullable(),
270
+                                ])->visible(fn (Get $get):bool => $get("video_type") == 2)->columnSpanFull(),
271
+                            ]),
272
+                        ])->visible(fn (Get $get):bool => $get("paragraph_type") == 3),
270 273
                     ])
271 274
                     ->relationship("paragraphs")
272 275
                     ->label("段落")

+ 1
- 1
app/Http/Controllers/Api/NewsController.php View File

@@ -259,7 +259,7 @@ class NewsController extends Controller
259 259
                         "video_img_url" => $paragraph->paragraph_video_img,
260 260
                         "is_yt" => $paragraph->video_type == 1 ? true : false,
261 261
                         "content" => $paragraph->getTranslation("video_img_alt", $locate, false),
262
-                        "video_url" => $paragraph->paragraph_video_url,
262
+                        "video_url" => $paragraph->getTranslation("link", $locate, false),
263 263
                     ];
264 264
                     break;
265 265
             }

+ 1
- 1
app/Models/NewsParagraph.php View File

@@ -20,7 +20,7 @@ class NewsParagraph extends Model
20 20
     protected $guarded = ['id'];
21 21
     public $timestamps = false;
22 22
     protected $appends = ['paragraph_video_img', 'paragraph_video_type', 'paragraph_video_url'];
23
-    public $translatable = ['video_img_alt'];
23
+    public $translatable = ['video_img_alt', 'link'];
24 24
     protected $casts = [
25 25
         'text_content' => 'array',         // JSON 轉陣列
26 26
     ];