parent
commit
06745ec69b
2 changed files with 3 additions and 14 deletions
  1. 2
    13
      app/Filament/Resources/ProjectResource.php
  2. 1
    1
      app/Models/Project.php

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

@@ -99,13 +99,7 @@ class ProjectResource extends Resource
99 99
                                 ->searchable()
100 100
                                 ->label('')
101 101
                                 ->required(),
102
-                        ])->reorderable(false)
103
-                        // ✅ 加上這個!
104
-                        ->mutateRelationshipDataBeforeCreateUsing(function (array $data): array {
105
-                            $data['award_type'] = 1;  // 確保有值
106
-                            $data['award_date'] = null;  // 確保有值
107
-                            return $data;
108
-                        }),
102
+                        ])->reorderable(false),
109 103
                         Repeater::make("badgesAward")->label("取得標章")->schema([
110 104
                             Hidden::make("award_type")->default(2),
111 105
                             Select::make('badge_id')
@@ -127,12 +121,7 @@ class ProjectResource extends Resource
127 121
                                 ->displayFormat('Y年m月')
128 122
                                 ->native(false)
129 123
                                 ->closeOnDateSelection()
130
-                        ])->reorderable(false)
131
-                        // ✅ 加上這個!
132
-                        ->mutateRelationshipDataBeforeCreateUsing(function (array $data): array {
133
-                            $data['award_type'] = 2;  // 確保有值
134
-                            return $data;
135
-                        }),
124
+                        ])->reorderable(false),
136 125
                     ]),
137 126
                     Tab::make("開發歷程")->schema([
138 127
                         Repeater::make("histories")->label("")->schema([

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

@@ -81,7 +81,7 @@ class Project extends Model
81 81
     public function firstListImgUrl(): Attribute
82 82
     {
83 83
         return Attribute::make(
84
-            get: fn ($value) => is_null($this->img_url) ? null :Storage::url($this->img_url[0]),
84
+            get: fn ($value) => empty($this->img_url) ? null : is_array($this->img_url)? Storage::url($this->img_url[0]) : Storage::url($this->img_url),
85 85
         );
86 86
     }
87 87