|
|
|
|
|
|
12
|
use Filament\Forms\Components\Group;
|
12
|
use Filament\Forms\Components\Group;
|
|
13
|
use Filament\Forms\Components\Radio;
|
13
|
use Filament\Forms\Components\Radio;
|
|
14
|
use Filament\Forms\Components\Repeater;
|
14
|
use Filament\Forms\Components\Repeater;
|
|
|
|
15
|
+use Filament\Forms\Components\RichEditor;
|
|
15
|
use Filament\Forms\Components\Section;
|
16
|
use Filament\Forms\Components\Section;
|
|
16
|
use Filament\Forms\Components\Select;
|
17
|
use Filament\Forms\Components\Select;
|
|
17
|
use Filament\Forms\Components\Tabs;
|
18
|
use Filament\Forms\Components\Tabs;
|
|
|
|
|
|
|
49
|
return $form
|
50
|
return $form
|
|
50
|
->schema([
|
51
|
->schema([
|
|
51
|
Section::make('')->schema([
|
52
|
Section::make('')->schema([
|
|
52
|
- Translate::make()->schema(fn (string $locale) => [
|
|
|
|
|
|
53
|
+ Translate::make()->schema(fn(string $locale) => [
|
|
53
|
TextInput::make('name')->label('項目名稱')->required(),
|
54
|
TextInput::make('name')->label('項目名稱')->required(),
|
|
54
|
TextInput::make('sub_name')->label('項目子名稱')->required(),
|
55
|
TextInput::make('sub_name')->label('項目子名稱')->required(),
|
|
55
|
])
|
56
|
])
|
|
|
|
|
|
|
82
|
Select::make('region_id')->label('地區')->options(function () {
|
83
|
Select::make('region_id')->label('地區')->options(function () {
|
|
83
|
return Region::where('visible', true)->pluck('name', 'id');
|
84
|
return Region::where('visible', true)->pluck('name', 'id');
|
|
84
|
})->required(),
|
85
|
})->required(),
|
|
85
|
- Translate::make()->schema(fn (string $locale) => [
|
|
|
|
|
|
86
|
+ Translate::make()->schema(fn(string $locale) => [
|
|
86
|
Textarea::make('summaries')->label('簡述'),
|
87
|
Textarea::make('summaries')->label('簡述'),
|
|
87
|
TextInput::make('district')->label('區域'),
|
88
|
TextInput::make('district')->label('區域'),
|
|
88
|
TextInput::make('address')->label('地址'),
|
89
|
TextInput::make('address')->label('地址'),
|
|
|
|
|
|
|
102
|
return Badge::all()->mapWithKeys(function ($badge) {
|
103
|
return Badge::all()->mapWithKeys(function ($badge) {
|
|
103
|
return [
|
104
|
return [
|
|
104
|
$badge->id => '<div class="flex items-center gap-2">
|
105
|
$badge->id => '<div class="flex items-center gap-2">
|
|
105
|
- <img src="'.Storage::url($badge->img_url).'" class="w-6 h-6 rounded-full">
|
|
|
|
106
|
- <span>'.$badge->title.'</span>
|
|
|
|
|
|
106
|
+ <img src="' . Storage::url($badge->img_url) . '" class="w-6 h-6 rounded-full">
|
|
|
|
107
|
+ <span>' . $badge->title . '</span>
|
|
107
|
</div>',
|
108
|
</div>',
|
|
108
|
];
|
109
|
];
|
|
109
|
});
|
110
|
});
|
|
|
|
|
|
|
116
|
])
|
117
|
])
|
|
117
|
->reorderableWithButtons()
|
118
|
->reorderableWithButtons()
|
|
118
|
->defaultItems(0)
|
119
|
->defaultItems(0)
|
|
119
|
- ->visible(fn ($get) => $get('badge_type') == 1),
|
|
|
|
|
|
120
|
+ ->visible(fn($get) => $get('badge_type') == 1),
|
|
120
|
Repeater::make('badgesAward')->label('取得標章')->schema([
|
121
|
Repeater::make('badgesAward')->label('取得標章')->schema([
|
|
121
|
Select::make('badge_id')
|
122
|
Select::make('badge_id')
|
|
122
|
->options(function () {
|
123
|
->options(function () {
|
|
123
|
return Badge::all()->mapWithKeys(function ($badge) {
|
124
|
return Badge::all()->mapWithKeys(function ($badge) {
|
|
124
|
return [
|
125
|
return [
|
|
125
|
$badge->id => '<div class="flex items-center gap-2">
|
126
|
$badge->id => '<div class="flex items-center gap-2">
|
|
126
|
- <img src="'.Storage::url($badge->img_url).'" class="w-6 h-6 rounded-full">
|
|
|
|
127
|
- <span>'.$badge->title.'</span>
|
|
|
|
|
|
127
|
+ <img src="' . Storage::url($badge->img_url) . '" class="w-6 h-6 rounded-full">
|
|
|
|
128
|
+ <span>' . $badge->title . '</span>
|
|
128
|
</div>',
|
129
|
</div>',
|
|
129
|
];
|
130
|
];
|
|
130
|
});
|
131
|
});
|
|
|
|
|
|
|
143
|
])
|
144
|
])
|
|
144
|
->reorderableWithButtons()
|
145
|
->reorderableWithButtons()
|
|
145
|
->defaultItems(0)
|
146
|
->defaultItems(0)
|
|
146
|
- ->visible(fn ($get) => $get('badge_type') == 2),
|
|
|
|
|
|
147
|
+ ->visible(fn($get) => $get('badge_type') == 2),
|
|
147
|
]),
|
148
|
]),
|
|
148
|
Tab::make('開發歷程')->schema([
|
149
|
Tab::make('開發歷程')->schema([
|
|
149
|
Repeater::make('histories')->label('')->schema([
|
150
|
Repeater::make('histories')->label('')->schema([
|
|
150
|
TextInput::make('histories_item_key')
|
151
|
TextInput::make('histories_item_key')
|
|
151
|
- ->default(fn () => Str::random())
|
|
|
|
|
|
152
|
+ ->default(fn() => Str::random())
|
|
152
|
->hidden()
|
153
|
->hidden()
|
|
153
|
->afterStateHydrated(function (TextInput $component, $state) {
|
154
|
->afterStateHydrated(function (TextInput $component, $state) {
|
|
154
|
if (empty($state)) {
|
155
|
if (empty($state)) {
|
|
|
|
|
|
|
156
|
}
|
157
|
}
|
|
157
|
}),
|
158
|
}),
|
|
158
|
DatePicker::make('operate_date')->label('歷程日期')->columnSpan(1)->required(),
|
159
|
DatePicker::make('operate_date')->label('歷程日期')->columnSpan(1)->required(),
|
|
159
|
- Translate::make()->schema(fn (string $locale) => [
|
|
|
|
|
|
160
|
+ Translate::make()->schema(fn(string $locale) => [
|
|
160
|
TextInput::make('title')->label('標題')->columnSpanFull()->required(),
|
161
|
TextInput::make('title')->label('標題')->columnSpanFull()->required(),
|
|
161
|
])
|
162
|
])
|
|
162
|
->locales(['zh_TW', 'en'])
|
163
|
->locales(['zh_TW', 'en'])
|
|
163
|
->actions([
|
164
|
->actions([
|
|
164
|
app(DeepLService::class)->createTranslationAction('histories', ['title']),
|
165
|
app(DeepLService::class)->createTranslationAction('histories', ['title']),
|
|
165
|
])->columnSpanFull()
|
166
|
])->columnSpanFull()
|
|
166
|
- ->id(fn ($get) => 'histories_'.$get('histories_item_key')),
|
|
|
|
|
|
167
|
+ ->id(fn($get) => 'histories_' . $get('histories_item_key')),
|
|
167
|
])
|
168
|
])
|
|
168
|
->relationship('histories')
|
169
|
->relationship('histories')
|
|
169
|
->reorderableWithButtons()
|
170
|
->reorderableWithButtons()
|
|
|
|
|
|
|
173
|
]),
|
174
|
]),
|
|
174
|
Tab::make('空間資訊')->schema([
|
175
|
Tab::make('空間資訊')->schema([
|
|
175
|
Group::make()->schema([
|
176
|
Group::make()->schema([
|
|
176
|
- Translate::make()->schema(fn (string $locale) => [
|
|
|
|
|
|
177
|
+ Translate::make()->schema(fn(string $locale) => [
|
|
177
|
// TextInput::make('contact_unit')->label('物管單位'),
|
178
|
// TextInput::make('contact_unit')->label('物管單位'),
|
|
178
|
TextInput::make('contact_phone')->label('物管電話'),
|
179
|
TextInput::make('contact_phone')->label('物管電話'),
|
|
179
|
TextInput::make('inversment_phone')->label('招商電話'),
|
180
|
TextInput::make('inversment_phone')->label('招商電話'),
|
|
|
|
|
|
|
187
|
])->columnSpanFull(),
|
188
|
])->columnSpanFull(),
|
|
188
|
Repeater::make('spaceInfos')->label('')->schema([
|
189
|
Repeater::make('spaceInfos')->label('')->schema([
|
|
189
|
TextInput::make('spaceInfos_item_key')
|
190
|
TextInput::make('spaceInfos_item_key')
|
|
190
|
- ->default(fn () => Str::random())
|
|
|
|
|
|
191
|
+ ->default(fn() => Str::random())
|
|
191
|
->hidden()
|
192
|
->hidden()
|
|
192
|
->afterStateHydrated(function (TextInput $component, $state) {
|
193
|
->afterStateHydrated(function (TextInput $component, $state) {
|
|
193
|
if (empty($state)) {
|
194
|
if (empty($state)) {
|
|
194
|
$component->state(Str::random());
|
195
|
$component->state(Str::random());
|
|
195
|
}
|
196
|
}
|
|
196
|
}),
|
197
|
}),
|
|
197
|
- Translate::make()->schema(fn (string $locale) => [
|
|
|
|
|
|
198
|
+ Translate::make()->schema(fn(string $locale) => [
|
|
198
|
TextInput::make('title')->label('標題')->columnSpanFull()->required(),
|
199
|
TextInput::make('title')->label('標題')->columnSpanFull()->required(),
|
|
199
|
- Textarea::make('content')->label('內文')->columnSpanFull()->required(),
|
|
|
|
|
|
200
|
+ RichEditor::make('content')->label('內文')->columnSpanFull()->required()
|
|
|
|
201
|
+ ->toolbarButtons(['bold', 'italic', 'underline', 'link', 'redo', 'undo']),
|
|
200
|
])
|
202
|
])
|
|
201
|
->locales(['zh_TW', 'en'])
|
203
|
->locales(['zh_TW', 'en'])
|
|
202
|
->actions([
|
204
|
->actions([
|
|
203
|
app(DeepLService::class)->createTranslationAction('spaceInfos', ['title', 'content']),
|
205
|
app(DeepLService::class)->createTranslationAction('spaceInfos', ['title', 'content']),
|
|
204
|
])->columnSpanFull()
|
206
|
])->columnSpanFull()
|
|
205
|
- ->id(fn ($get) => 'spaceInfos_'.$get('spaceInfos_item_key')),
|
|
|
|
|
|
207
|
+ ->id(fn($get) => 'spaceInfos_' . $get('spaceInfos_item_key')),
|
|
206
|
])
|
208
|
])
|
|
207
|
->relationship('spaceInfos')
|
209
|
->relationship('spaceInfos')
|
|
208
|
->label('')
|
210
|
->label('')
|
|
|
|
|
|
|
224
|
ImageColumn::make('thumbnail_url')->label('縮圖')->alignCenter(),
|
226
|
ImageColumn::make('thumbnail_url')->label('縮圖')->alignCenter(),
|
|
225
|
ImageColumn::make('first_list_img_url')->label('列表圖')->alignCenter(),
|
227
|
ImageColumn::make('first_list_img_url')->label('列表圖')->alignCenter(),
|
|
226
|
TextColumn::make('region.name')->label('地址')->alignCenter()
|
228
|
TextColumn::make('region.name')->label('地址')->alignCenter()
|
|
227
|
- ->formatStateUsing(fn ($record) => $record->region->getTranslation('name', 'zh_TW').' | '.$record->getTranslation('address', 'zh_TW')),
|
|
|
|
|
|
229
|
+ ->formatStateUsing(fn($record) => $record->region->getTranslation('name', 'zh_TW') . ' | ' . $record->getTranslation('address', 'zh_TW')),
|
|
228
|
])
|
230
|
])
|
|
229
|
->filters([
|
231
|
->filters([
|
|
230
|
SelectFilter::make('visible')->label('上/下架')
|
232
|
SelectFilter::make('visible')->label('上/下架')
|
|
|
|
|
|
|
233
|
1 => '上架',
|
235
|
1 => '上架',
|
|
234
|
])
|
236
|
])
|
|
235
|
->query(
|
237
|
->query(
|
|
236
|
- fn (array $data, Builder $query): Builder => $query->when(
|
|
|
|
|
|
238
|
+ fn(array $data, Builder $query): Builder => $query->when(
|
|
237
|
$data['value'],
|
239
|
$data['value'],
|
|
238
|
- fn (Builder $query, $value): Builder => $query->where('visible', $data['value'])
|
|
|
|
|
|
240
|
+ fn(Builder $query, $value): Builder => $query->where('visible', $data['value'])
|
|
239
|
)
|
241
|
)
|
|
240
|
),
|
242
|
),
|
|
241
|
])
|
243
|
])
|
|
|
|
|
|
|
243
|
Tables\Actions\EditAction::make(),
|
245
|
Tables\Actions\EditAction::make(),
|
|
244
|
Tables\Actions\DeleteAction::make(),
|
246
|
Tables\Actions\DeleteAction::make(),
|
|
245
|
\Filament\Tables\Actions\Action::make('audit')
|
247
|
\Filament\Tables\Actions\Action::make('audit')
|
|
246
|
- ->label(fn ($record) => match ($record->visible) {
|
|
|
|
|
|
248
|
+ ->label(fn($record) => match ($record->visible) {
|
|
247
|
0 => '上架',
|
249
|
0 => '上架',
|
|
248
|
1 => '下架',
|
250
|
1 => '下架',
|
|
249
|
})
|
251
|
})
|
|
250
|
- ->color(fn ($record) => match ($record->visible) {
|
|
|
|
|
|
252
|
+ ->color(fn($record) => match ($record->visible) {
|
|
251
|
0 => 'warning',
|
253
|
0 => 'warning',
|
|
252
|
1 => 'gray',
|
254
|
1 => 'gray',
|
|
253
|
})
|
255
|
})
|
|
254
|
- ->icon(fn ($record) => match ($record->visible) {
|
|
|
|
|
|
256
|
+ ->icon(fn($record) => match ($record->visible) {
|
|
255
|
0 => 'heroicon-m-chevron-double-up',
|
257
|
0 => 'heroicon-m-chevron-double-up',
|
|
256
|
1 => 'heroicon-m-chevron-double-down',
|
258
|
1 => 'heroicon-m-chevron-double-down',
|
|
257
|
})
|
259
|
})
|
|
258
|
->action(function ($record): void {
|
260
|
->action(function ($record): void {
|
|
259
|
- $record->visible = ! $record->visible;
|
|
|
|
|
|
261
|
+ $record->visible = !$record->visible;
|
|
260
|
$record->save();
|
262
|
$record->save();
|
|
261
|
})
|
263
|
})
|
|
262
|
->outlined()
|
264
|
->outlined()
|