parent
commit
1ff294e5d3
1 changed files with 13 additions and 3 deletions
  1. 13
    3
      app/Filament/Resources/ProjectResource.php

+ 13
- 3
app/Filament/Resources/ProjectResource.php View File

@@ -99,11 +99,16 @@ class ProjectResource extends Resource
99 99
                                 ->searchable()
100 100
                                 ->label('')
101 101
                                 ->required(),
102
-                        ])->reorderable(false),
102
+                        ])->reorderable(false)
103
+                        // ✅ 加上這個!
104
+                        ->mutateRelationshipDataBeforeCreateUsing(function (array $data): array {
105
+                            $data['award_type'] = 1;  // 確保有值
106
+                            $data['award_date'] = null;  // 確保有值
107
+                            return $data;
108
+                        }),
103 109
                         Repeater::make("badgesAward")->label("取得標章")->schema([
104 110
                             Hidden::make("award_type")->default(2),
105 111
                             Select::make('badge_id')
106
-                                ->relationship('badges', 'title')
107 112
                                 ->getOptionLabelFromRecordUsing(function ($record) {
108 113
                                     $imageHtml = $record->img_url
109 114
                                         ? '<img src="' . Storage::url($record->img_url) . '" class="w-6 h-6 rounded-full mr-2 inline-block" />'
@@ -122,7 +127,12 @@ class ProjectResource extends Resource
122 127
                                 ->displayFormat('Y年m月')
123 128
                                 ->native(false)
124 129
                                 ->closeOnDateSelection()
125
-                        ])->reorderable(false),
130
+                        ])->reorderable(false)
131
+                        // ✅ 加上這個!
132
+                        ->mutateRelationshipDataBeforeCreateUsing(function (array $data): array {
133
+                            $data['award_type'] = 2;  // 確保有值
134
+                            return $data;
135
+                        }),
126 136
                     ]),
127 137
                     Tab::make("開發歷程")->schema([
128 138
                         Repeater::make("histories")->label("")->schema([