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
                                 ->searchable()
99
                                 ->searchable()
100
                                 ->label('')
100
                                 ->label('')
101
                                 ->required(),
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
                         Repeater::make("badgesAward")->label("取得標章")->schema([
109
                         Repeater::make("badgesAward")->label("取得標章")->schema([
104
                             Hidden::make("award_type")->default(2),
110
                             Hidden::make("award_type")->default(2),
105
                             Select::make('badge_id')
111
                             Select::make('badge_id')
106
-                                ->relationship('badges', 'title')
107
                                 ->getOptionLabelFromRecordUsing(function ($record) {
112
                                 ->getOptionLabelFromRecordUsing(function ($record) {
108
                                     $imageHtml = $record->img_url
113
                                     $imageHtml = $record->img_url
109
                                         ? '<img src="' . Storage::url($record->img_url) . '" class="w-6 h-6 rounded-full mr-2 inline-block" />'
114
                                         ? '<img src="' . Storage::url($record->img_url) . '" class="w-6 h-6 rounded-full mr-2 inline-block" />'
122
                                 ->displayFormat('Y年m月')
127
                                 ->displayFormat('Y年m月')
123
                                 ->native(false)
128
                                 ->native(false)
124
                                 ->closeOnDateSelection()
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
                     Tab::make("開發歷程")->schema([
137
                     Tab::make("開發歷程")->schema([
128
                         Repeater::make("histories")->label("")->schema([
138
                         Repeater::make("histories")->label("")->schema([