Browse Source

Banner add column type

parent
commit
9a563ddf87

+ 1
- 0
app/Filament/Resources/BannerResource.php View File

@@ -57,6 +57,7 @@ class BannerResource extends Resource
57 57
                         ->actions([
58 58
                             app(DeepLService::class)->createTranslationAction("Main", ["title", "content"])
59 59
                         ])->columnSpanFull(),
60
+                        Radio::make("type")->label("")->default(1)->options([1 => "圖片", 2 => "影片"]),
60 61
                         Group::make()->schema([
61 62
                             FileUpload::make("img_url")->label("圖片")->directory("banners")->columnSpan(1),
62 63
                             FileUpload::make("mobile_img")->label("手機板圖片")->directory("banners")->columnSpan(1),

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

@@ -32,6 +32,7 @@ class HomePageController extends Controller
32 32
             $result[] = [
33 33
                 "imgUrl" => $record->imgUrlLink,
34 34
                 "mobileImgUrl" => $record->mobileImgLink,
35
+                "type" => $record->type,
35 36
                 "title" => $record->getTranslation("title", $locale),
36 37
                 "content" => $record->getTranslation("content", $locale),
37 38
             ];

+ 28
- 0
database/migrations/2025_11_06_091741_alter_table_banners_add_column_type.php View File

@@ -0,0 +1,28 @@
1
+<?php
2
+
3
+use Illuminate\Database\Migrations\Migration;
4
+use Illuminate\Database\Schema\Blueprint;
5
+use Illuminate\Support\Facades\Schema;
6
+
7
+return new class extends Migration
8
+{
9
+    /**
10
+     * Run the migrations.
11
+     */
12
+    public function up(): void
13
+    {
14
+        Schema::table("banners", function (Blueprint $table) {
15
+            $table->integer("type")->default(1)->comment("1.圖片 2.影片");
16
+        });
17
+    }
18
+
19
+    /**
20
+     * Reverse the migrations.
21
+     */
22
+    public function down(): void
23
+    {
24
+        Schema::table("banners", function (Blueprint $table) {
25
+            $table->dropColumn("type");
26
+        });
27
+    }
28
+};