|
|
@@ -5,6 +5,7 @@ namespace App\Filament\Resources;
|
|
5
|
5
|
use AbdulmajeedJamaan\FilamentTranslatableTabs\TranslatableTabs;
|
|
6
|
6
|
use App\Filament\Resources\ProjectResource\Pages;
|
|
7
|
7
|
use App\Filament\Resources\ProjectResource\RelationManagers;
|
|
|
8
|
+use App\Models\Badge;
|
|
8
|
9
|
use App\Models\Project;
|
|
9
|
10
|
use App\Models\Region;
|
|
10
|
11
|
use Filament\Forms;
|
|
|
@@ -82,17 +83,19 @@ class ProjectResource extends Resource
|
|
82
|
83
|
app(DeepLService::class)->createTranslationAction("summaries", ["summaries","address",
|
|
83
|
84
|
"floor_plan","building_structure","design_unit"])
|
|
84
|
85
|
])->columnSpanFull()->id("summaries"),
|
|
85
|
|
- Radio::make("badge_type")->label("標章呈現方式")->options([1 => "永續目標", 2 => "取得標章"])->default(1)->inline(),
|
|
|
86
|
+ Radio::make("badge_type")->label("")->options([1 => "永續目標", 2 => "取得標章"])->default(1)->inline(),
|
|
86
|
87
|
Repeater::make("badgesTarget")->label("永續目標")->schema([
|
|
87
|
88
|
Hidden::make("award_type")->default(1),
|
|
88
|
89
|
Select::make('badge_id')
|
|
89
|
|
- ->relationship('badges', 'title')
|
|
90
|
|
- ->getOptionLabelFromRecordUsing(function ($record) {
|
|
91
|
|
- $imageHtml = $record->img_url
|
|
92
|
|
- ? '<img src="' . Storage::url($record->img_url) . '" class="w-6 h-6 rounded-full mr-2 inline-block" />'
|
|
93
|
|
- : '<div class="w-6 h-6 bg-gray-200 rounded-full mr-2 inline-block"></div>';
|
|
94
|
|
-
|
|
95
|
|
- return new \Illuminate\Support\HtmlString($imageHtml . $record->title);
|
|
|
90
|
+ ->options(function () {
|
|
|
91
|
+ return Badge::all()->mapWithKeys(function ($badge) {
|
|
|
92
|
+ return [
|
|
|
93
|
+ $badge->id => '<div class="flex items-center gap-2">
|
|
|
94
|
+ <img src="' . Storage::url($badge->img_url) . '" class="w-6 h-6 rounded-full">
|
|
|
95
|
+ <span>' . $badge->title . '</span>
|
|
|
96
|
+ </div>'
|
|
|
97
|
+ ];
|
|
|
98
|
+ });
|
|
96
|
99
|
})
|
|
97
|
100
|
->allowHtml()
|
|
98
|
101
|
->preload()
|
|
|
@@ -103,12 +106,15 @@ class ProjectResource extends Resource
|
|
103
|
106
|
Repeater::make("badgesAward")->label("取得標章")->schema([
|
|
104
|
107
|
Hidden::make("award_type")->default(2),
|
|
105
|
108
|
Select::make('badge_id')
|
|
106
|
|
- ->getOptionLabelFromRecordUsing(function ($record) {
|
|
107
|
|
- $imageHtml = $record->img_url
|
|
108
|
|
- ? '<img src="' . Storage::url($record->img_url) . '" class="w-6 h-6 rounded-full mr-2 inline-block" />'
|
|
109
|
|
- : '<div class="w-6 h-6 bg-gray-200 rounded-full mr-2 inline-block"></div>';
|
|
110
|
|
-
|
|
111
|
|
- return new \Illuminate\Support\HtmlString($imageHtml . $record->title);
|
|
|
109
|
+ ->options(function () {
|
|
|
110
|
+ return Badge::all()->mapWithKeys(function ($badge) {
|
|
|
111
|
+ return [
|
|
|
112
|
+ $badge->id => '<div class="flex items-center gap-2">
|
|
|
113
|
+ <img src="' . Storage::url($badge->img_url) . '" class="w-6 h-6 rounded-full">
|
|
|
114
|
+ <span>' . $badge->title . '</span>
|
|
|
115
|
+ </div>'
|
|
|
116
|
+ ];
|
|
|
117
|
+ });
|
|
112
|
118
|
})
|
|
113
|
119
|
->allowHtml()
|
|
114
|
120
|
->preload()
|