Andrew преди 1 месец
родител
ревизия
d4802081fd

+ 8
- 8
app/Filament/Resources/ProjectResource.php Целия файл

@@ -50,8 +50,8 @@ class ProjectResource extends Resource
50 50
             ->schema([
51 51
                 Section::make('')->schema([
52 52
                     Translate::make()->schema(fn (string $locale) => [
53
-                        TextInput::make('name')->label('項目名稱'),
54
-                        TextInput::make('sub_name')->label('項目子名稱'),
53
+                        TextInput::make('name')->label('項目名稱')->required(),
54
+                        TextInput::make('sub_name')->label('項目子名稱')->required(),
55 55
                     ])
56 56
                         ->locales(['zh_TW', 'en'])
57 57
                         ->actions([
@@ -70,12 +70,12 @@ class ProjectResource extends Resource
70 70
                         ->image()
71 71
                         ->optimize('webp')
72 72
                         ->maxImageWidth(1920)
73
-                        ->acceptedFileTypes(['image/jpeg', 'image/jpg', 'image/png', 'image/webp'])->required()->imageEditor()->multiple()->maxFiles(20),
73
+                        ->acceptedFileTypes(['image/jpeg', 'image/jpg', 'image/png', 'image/webp'])->imageEditor()->multiple()->maxFiles(20),
74 74
                     FileUpload::make('mobile_img_url')->label('手機版圖片')->directory('project')->reorderable()
75 75
                         ->image()
76 76
                         ->optimize('webp')
77 77
                         ->maxImageWidth(1920)
78
-                        ->acceptedFileTypes(['image/jpeg', 'image/jpg', 'image/png', 'image/webp'])->required()->imageEditor()->multiple()->maxFiles(20),
78
+                        ->acceptedFileTypes(['image/jpeg', 'image/jpg', 'image/png', 'image/webp'])->imageEditor()->multiple()->maxFiles(20),
79 79
                 ]),
80 80
                 Tabs::make()->schema([
81 81
                     Tab::make('專案概要')->schema([
@@ -155,9 +155,9 @@ class ProjectResource extends Resource
155 155
                                         $component->state(Str::random());
156 156
                                     }
157 157
                                 }),
158
-                            DatePicker::make('operate_date')->label('歷程日期')->columnSpan(1),
158
+                            DatePicker::make('operate_date')->label('歷程日期')->columnSpan(1)->required(),
159 159
                             Translate::make()->schema(fn (string $locale) => [
160
-                                TextInput::make('title')->label('標題')->columnSpanFull(),
160
+                                TextInput::make('title')->label('標題')->columnSpanFull()->required(),
161 161
                             ])
162 162
                                 ->locales(['zh_TW', 'en'])
163 163
                                 ->actions([
@@ -195,8 +195,8 @@ class ProjectResource extends Resource
195 195
                                     }
196 196
                                 }),
197 197
                             Translate::make()->schema(fn (string $locale) => [
198
-                                TextInput::make('title')->label('標題')->columnSpanFull(),
199
-                                Textarea::make('content')->label('內文')->columnSpanFull(),
198
+                                TextInput::make('title')->label('標題')->columnSpanFull()->required(),
199
+                                Textarea::make('content')->label('內文')->columnSpanFull()->required(),
200 200
                             ])
201 201
                                 ->locales(['zh_TW', 'en'])
202 202
                                 ->actions([

+ 62
- 0
database/migrations/2025_12_09_090012_add_default_values_to_projects_table.php Целия файл

@@ -0,0 +1,62 @@
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('projects', function (Blueprint $table) {
15
+            // Add default value for order column
16
+            $table->integer('order')->default(0)->change();
17
+
18
+            // Make region_id nullable since it's optional in the form
19
+            $table->foreignId('region_id')->nullable()->change();
20
+
21
+            // Make badge_type default to 1 (永續目標)
22
+            $table->tinyInteger('badge_type')->default(1)->change();
23
+
24
+            // Make various optional fields nullable
25
+            $table->json('mobile_img_url')->nullable()->change();
26
+            $table->string('thumbnail')->nullable()->change();
27
+            $table->json('summaries')->nullable()->change();
28
+            $table->json('address')->nullable()->change();
29
+            $table->json('floor_plan')->nullable()->change();
30
+            $table->json('building_structure')->nullable()->change();
31
+            $table->json('design_unit')->nullable()->change();
32
+            $table->json('contact_phone')->nullable()->change();
33
+            $table->json('inversment_phone')->nullable()->change();
34
+            $table->json('district')->nullable()->change();
35
+            $table->string('offical_link')->nullable()->change();
36
+        });
37
+    }
38
+
39
+    /**
40
+     * Reverse the migrations.
41
+     */
42
+    public function down(): void
43
+    {
44
+        Schema::table('projects', function (Blueprint $table) {
45
+            // Reverse changes - remove defaults and nullable constraints
46
+            $table->integer('order')->change();
47
+            $table->foreignId('region_id')->change();
48
+            $table->tinyInteger('badge_type')->change();
49
+            $table->json('mobile_img_url')->change();
50
+            $table->string('thumbnail')->change();
51
+            $table->json('summaries')->change();
52
+            $table->json('address')->change();
53
+            $table->json('floor_plan')->change();
54
+            $table->json('building_structure')->change();
55
+            $table->json('design_unit')->change();
56
+            $table->json('contact_phone')->change();
57
+            $table->json('inversment_phone')->change();
58
+            $table->json('district')->change();
59
+            $table->string('offical_link')->change();
60
+        });
61
+    }
62
+};

+ 30
- 0
database/migrations/2025_12_09_090018_add_order_column_to_project_histories_table.php Целия файл

@@ -0,0 +1,30 @@
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('project_histories', function (Blueprint $table) {
15
+            // Add default value to existing order column
16
+            $table->integer('order')->default(0)->change();
17
+        });
18
+    }
19
+
20
+    /**
21
+     * Reverse the migrations.
22
+     */
23
+    public function down(): void
24
+    {
25
+        Schema::table('project_histories', function (Blueprint $table) {
26
+            // Remove default value from order column
27
+            $table->integer('order')->change();
28
+        });
29
+    }
30
+};