|
|
@@ -51,7 +51,7 @@ class ProjectResource extends Resource
|
|
51
|
51
|
return $form
|
|
52
|
52
|
->schema([
|
|
53
|
53
|
Section::make('')->schema([
|
|
54
|
|
- Translate::make()->schema(fn (string $locale) => [
|
|
|
54
|
+ Translate::make()->schema(fn(string $locale) => [
|
|
55
|
55
|
TextInput::make('name')->label('項目名稱'),
|
|
56
|
56
|
TextInput::make('sub_name')->label('項目子名稱'),
|
|
57
|
57
|
])
|
|
|
@@ -77,7 +77,7 @@ class ProjectResource extends Resource
|
|
77
|
77
|
Select::make('region_id')->label('地區')->options(function () {
|
|
78
|
78
|
return Region::where('visible', true)->pluck('name', 'id');
|
|
79
|
79
|
}),
|
|
80
|
|
- Translate::make()->schema(fn (string $locale) => [
|
|
|
80
|
+ Translate::make()->schema(fn(string $locale) => [
|
|
81
|
81
|
Textarea::make('summaries')->label('簡述'),
|
|
82
|
82
|
TextInput::make('district')->label('區域'),
|
|
83
|
83
|
TextInput::make('address')->label('地址'),
|
|
|
@@ -98,8 +98,8 @@ class ProjectResource extends Resource
|
|
98
|
98
|
return Badge::all()->mapWithKeys(function ($badge) {
|
|
99
|
99
|
return [
|
|
100
|
100
|
$badge->id => '<div class="flex items-center gap-2">
|
|
101
|
|
- <img src="'.Storage::url($badge->img_url).'" class="w-6 h-6 rounded-full">
|
|
102
|
|
- <span>'.$badge->title.'</span>
|
|
|
101
|
+ <img src="' . Storage::url($badge->img_url) . '" class="w-6 h-6 rounded-full">
|
|
|
102
|
+ <span>' . $badge->title . '</span>
|
|
103
|
103
|
</div>',
|
|
104
|
104
|
];
|
|
105
|
105
|
});
|
|
|
@@ -117,8 +117,8 @@ class ProjectResource extends Resource
|
|
117
|
117
|
return Badge::all()->mapWithKeys(function ($badge) {
|
|
118
|
118
|
return [
|
|
119
|
119
|
$badge->id => '<div class="flex items-center gap-2">
|
|
120
|
|
- <img src="'.Storage::url($badge->img_url).'" class="w-6 h-6 rounded-full">
|
|
121
|
|
- <span>'.$badge->title.'</span>
|
|
|
120
|
+ <img src="' . Storage::url($badge->img_url) . '" class="w-6 h-6 rounded-full">
|
|
|
121
|
+ <span>' . $badge->title . '</span>
|
|
122
|
122
|
</div>',
|
|
123
|
123
|
];
|
|
124
|
124
|
});
|
|
|
@@ -139,7 +139,7 @@ class ProjectResource extends Resource
|
|
139
|
139
|
Tab::make('開發歷程')->schema([
|
|
140
|
140
|
Repeater::make('histories')->label('')->schema([
|
|
141
|
141
|
TextInput::make('histories_item_key')
|
|
142
|
|
- ->default(fn () => Str::random())
|
|
|
142
|
+ ->default(fn() => Str::random())
|
|
143
|
143
|
->hidden()
|
|
144
|
144
|
->afterStateHydrated(function (TextInput $component, $state) {
|
|
145
|
145
|
if (empty($state)) {
|
|
|
@@ -147,14 +147,14 @@ class ProjectResource extends Resource
|
|
147
|
147
|
}
|
|
148
|
148
|
}),
|
|
149
|
149
|
DatePicker::make('operate_date')->label('歷程日期')->columnSpan(1),
|
|
150
|
|
- Translate::make()->schema(fn (string $locale) => [
|
|
|
150
|
+ Translate::make()->schema(fn(string $locale) => [
|
|
151
|
151
|
TextInput::make('title')->label('標題')->columnSpanFull(),
|
|
152
|
152
|
])
|
|
153
|
153
|
->locales(['zh_TW', 'en'])
|
|
154
|
154
|
->actions([
|
|
155
|
155
|
app(DeepLService::class)->createTranslationAction('histories', ['title']),
|
|
156
|
156
|
])->columnSpanFull()
|
|
157
|
|
- ->id(fn ($get) => 'histories_'.$get('histories_item_key')),
|
|
|
157
|
+ ->id(fn($get) => 'histories_' . $get('histories_item_key')),
|
|
158
|
158
|
])
|
|
159
|
159
|
->relationship('histories', function ($query, Get $get, $livewire) {
|
|
160
|
160
|
return $query->orderby('operate_date', 'desc');
|
|
|
@@ -164,7 +164,7 @@ class ProjectResource extends Resource
|
|
164
|
164
|
]),
|
|
165
|
165
|
Tab::make('空間資訊')->schema([
|
|
166
|
166
|
Group::make()->schema([
|
|
167
|
|
- Translate::make()->schema(fn (string $locale) => [
|
|
|
167
|
+ Translate::make()->schema(fn(string $locale) => [
|
|
168
|
168
|
TextInput::make('contact_unit')->label('物管單位'),
|
|
169
|
169
|
TextInput::make('contact_phone')->label('物管電話'),
|
|
170
|
170
|
TextInput::make('inversment_phone')->label('招商電話'),
|
|
|
@@ -177,15 +177,16 @@ class ProjectResource extends Resource
|
|
177
|
177
|
TextInput::make('offical_link')->label('官網連結'),
|
|
178
|
178
|
])->columnSpanFull(),
|
|
179
|
179
|
Repeater::make('spaceInfos')->label('')->schema([
|
|
180
|
|
- Translate::make()->schema(fn (string $locale) => [
|
|
|
180
|
+ Translate::make()->schema(fn(string $locale) => [
|
|
181
|
181
|
TextInput::make('title')->label('標題')->columnSpanFull(),
|
|
182
|
182
|
Textarea::make('content')->label('內文')->columnSpanFull(),
|
|
183
|
183
|
])
|
|
184
|
184
|
->locales(['zh_TW', 'en'])
|
|
185
|
|
- ->actions([
|
|
186
|
|
- app(DeepLService::class)->createTranslationAction('spaceInfos', ['title', 'content']),
|
|
187
|
|
- ])->columnSpanFull()
|
|
188
|
|
- ->id(fn ($get) => 'spaceInfos_'.$get('item_key')),
|
|
|
185
|
+ ->actions(fn($arguments) => $arguments['locale'] === 'zh_TW' ? [] : [
|
|
|
186
|
+ app(DeepLService::class)->createTranslationAction('spaceInfos', ['title', 'content'])
|
|
|
187
|
+ ])
|
|
|
188
|
+ ->columnSpanFull()
|
|
|
189
|
+ ->id(fn($get) => 'spaceInfos_' . $get('item_key')),
|
|
189
|
190
|
])
|
|
190
|
191
|
->relationship('spaceInfos')
|
|
191
|
192
|
->label('')
|
|
|
@@ -207,7 +208,7 @@ class ProjectResource extends Resource
|
|
207
|
208
|
ImageColumn::make('thumbnail_url')->label('縮圖')->alignCenter(),
|
|
208
|
209
|
ImageColumn::make('first_list_img_url')->label('列表圖')->alignCenter(),
|
|
209
|
210
|
TextColumn::make('region.name')->label('地址')->alignCenter()
|
|
210
|
|
- ->formatStateUsing(fn ($record) => $record->region->getTranslation('name', 'zh_TW').' | '.$record->getTranslation('address', 'zh_TW')),
|
|
|
211
|
+ ->formatStateUsing(fn($record) => $record->region->getTranslation('name', 'zh_TW') . ' | ' . $record->getTranslation('address', 'zh_TW')),
|
|
211
|
212
|
])
|
|
212
|
213
|
->filters([
|
|
213
|
214
|
SelectFilter::make('visible')->label('上/下架')
|
|
|
@@ -216,9 +217,9 @@ class ProjectResource extends Resource
|
|
216
|
217
|
1 => '上架',
|
|
217
|
218
|
])
|
|
218
|
219
|
->query(
|
|
219
|
|
- fn (array $data, Builder $query): Builder => $query->when(
|
|
|
220
|
+ fn(array $data, Builder $query): Builder => $query->when(
|
|
220
|
221
|
$data['value'],
|
|
221
|
|
- fn (Builder $query, $value): Builder => $query->where('visible', $data['value'])
|
|
|
222
|
+ fn(Builder $query, $value): Builder => $query->where('visible', $data['value'])
|
|
222
|
223
|
)
|
|
223
|
224
|
),
|
|
224
|
225
|
])
|
|
|
@@ -226,20 +227,20 @@ class ProjectResource extends Resource
|
|
226
|
227
|
Tables\Actions\EditAction::make(),
|
|
227
|
228
|
Tables\Actions\DeleteAction::make(),
|
|
228
|
229
|
\Filament\Tables\Actions\Action::make('audit')
|
|
229
|
|
- ->label(fn ($record) => match ($record->visible) {
|
|
|
230
|
+ ->label(fn($record) => match ($record->visible) {
|
|
230
|
231
|
0 => '上架',
|
|
231
|
232
|
1 => '下架',
|
|
232
|
233
|
})
|
|
233
|
|
- ->color(fn ($record) => match ($record->visible) {
|
|
|
234
|
+ ->color(fn($record) => match ($record->visible) {
|
|
234
|
235
|
0 => 'warning',
|
|
235
|
236
|
1 => 'gray',
|
|
236
|
237
|
})
|
|
237
|
|
- ->icon(fn ($record) => match ($record->visible) {
|
|
|
238
|
+ ->icon(fn($record) => match ($record->visible) {
|
|
238
|
239
|
0 => 'heroicon-m-chevron-double-up',
|
|
239
|
240
|
1 => 'heroicon-m-chevron-double-down',
|
|
240
|
241
|
})
|
|
241
|
242
|
->action(function ($record): void {
|
|
242
|
|
- $record->visible = ! $record->visible;
|
|
|
243
|
+ $record->visible = !$record->visible;
|
|
243
|
244
|
$record->save();
|
|
244
|
245
|
})
|
|
245
|
246
|
->outlined()
|