|
|
@@ -66,7 +66,7 @@ class AlbumResource extends Resource
|
|
66
|
66
|
FileUpload::make('news_img_mobile')->label('列表圖(mobile)')
|
|
67
|
67
|
->directory('album/img')
|
|
68
|
68
|
->acceptedFileTypes(['image/jpeg', 'image/jpg', 'image/png', 'image/webp'])->required()->imageEditor(),
|
|
69
|
|
- Translate::make()->schema(fn (string $locale) => [
|
|
|
69
|
+ Translate::make()->schema(fn(string $locale) => [
|
|
70
|
70
|
TextInput::make('title')
|
|
71
|
71
|
->label('標題')
|
|
72
|
72
|
->columnSpan(1),
|
|
|
@@ -84,17 +84,16 @@ class AlbumResource extends Resource
|
|
84
|
84
|
])->columnSpanFull()->default(1)->live(),
|
|
85
|
85
|
Group::make()->schema([
|
|
86
|
86
|
TextInput::make('link_video')->label('網址')->nullable(),
|
|
87
|
|
- ])->visible(fn (Get $get): bool => $get('upload_type') == 1)->columnSpanFull(),
|
|
|
87
|
+ ])->visible(fn(Get $get): bool => $get('upload_type') == 1)->columnSpanFull(),
|
|
88
|
88
|
Group::make()->schema([
|
|
89
|
89
|
FileUpload::make('link_upload')->label('')->directory('album/video')
|
|
90
|
90
|
->acceptedFileTypes(['video/mp4', 'video/mpeg', 'video/quicktime', 'video/x-msvideo', 'video/x-ms-wmv'])
|
|
91
|
91
|
->helperText('建議影片寬高限制為:1920*1080px,出血寬度720px,大小限制為:100M以下')
|
|
92
|
92
|
->maxSize(102400)->nullable(),
|
|
93
|
|
- ])->visible(fn (Get $get): bool => $get('upload_type') == 2)->columnSpanFull(),
|
|
|
93
|
+ ])->visible(fn(Get $get): bool => $get('upload_type') == 2)->columnSpanFull(),
|
|
94
|
94
|
])->columnSpanFull(),
|
|
95
|
95
|
Toggle::make('on_top')->inline()->label('置頂輪播')->columnSpanFull(),
|
|
96
|
96
|
Toggle::make('homepage_top')->inline()->label('在首頁輪播')->columnSpanFull(),
|
|
97
|
|
- TextInput::make('order')->label('排序')->integer()->default(0),
|
|
98
|
97
|
])->columns(3),
|
|
99
|
98
|
]);
|
|
100
|
99
|
}
|
|
|
@@ -109,7 +108,7 @@ class AlbumResource extends Resource
|
|
109
|
108
|
TextColumn::make('post_date')->date()->alignCenter(),
|
|
110
|
109
|
ImageColumn::make('news_img_pc')->alignCenter(),
|
|
111
|
110
|
TextColumn::make('list_audit_state')->label('狀態')->badge()
|
|
112
|
|
- ->color(fn (string $state): string => match ($state) {
|
|
|
111
|
+ ->color(fn(string $state): string => match ($state) {
|
|
113
|
112
|
'暫存' => 'warning',
|
|
114
|
113
|
'已發佈' => 'success',
|
|
115
|
114
|
}),
|
|
|
@@ -120,23 +119,23 @@ class AlbumResource extends Resource
|
|
120
|
119
|
SelectFilter::make('post_date')->label('年份')
|
|
121
|
120
|
->options(Album::select(DB::raw("DATE_FORMAT(post_date, '%Y') as year"))->whereNotNull('post_date')->distinct()->pluck('year', 'year')->toArray())
|
|
122
|
121
|
->query(
|
|
123
|
|
- fn (array $data, Builder $query): Builder => $query->when(
|
|
|
122
|
+ fn(array $data, Builder $query): Builder => $query->when(
|
|
124
|
123
|
$data['value'],
|
|
125
|
|
- fn (Builder $query, $value): Builder => $query->where('post_date', 'like', $data['value'].'%')
|
|
|
124
|
+ fn(Builder $query, $value): Builder => $query->where('post_date', 'like', $data['value'] . '%')
|
|
126
|
125
|
)
|
|
127
|
126
|
),
|
|
128
|
127
|
SelectFilter::make('album_category_id')->label('分類')
|
|
129
|
128
|
->relationship('albumCategory', 'name')
|
|
130
|
|
- ->getOptionLabelFromRecordUsing(fn ($record, $livewire) => $record->getTranslation('name', 'zh_TW')),
|
|
|
129
|
+ ->getOptionLabelFromRecordUsing(fn($record, $livewire) => $record->getTranslation('name', 'zh_TW')),
|
|
131
|
130
|
SelectFilter::make('visible')->label('狀態')
|
|
132
|
131
|
->options([
|
|
133
|
132
|
0 => '暫存',
|
|
134
|
133
|
1 => '已發佈',
|
|
135
|
134
|
])
|
|
136
|
135
|
->query(
|
|
137
|
|
- fn (array $data, Builder $query): Builder => $query->when(
|
|
|
136
|
+ fn(array $data, Builder $query): Builder => $query->when(
|
|
138
|
137
|
$data['value'],
|
|
139
|
|
- fn (Builder $query, $value): Builder => $query->where('visible', $data['value'])
|
|
|
138
|
+ fn(Builder $query, $value): Builder => $query->where('visible', $data['value'])
|
|
140
|
139
|
)
|
|
141
|
140
|
),
|
|
142
|
141
|
])
|
|
|
@@ -144,20 +143,20 @@ class AlbumResource extends Resource
|
|
144
|
143
|
Tables\Actions\EditAction::make(),
|
|
145
|
144
|
Tables\Actions\DeleteAction::make(),
|
|
146
|
145
|
\Filament\Tables\Actions\Action::make('audit')
|
|
147
|
|
- ->label(fn ($record) => match ($record->visible) {
|
|
|
146
|
+ ->label(fn($record) => match ($record->visible) {
|
|
148
|
147
|
0 => '發佈',
|
|
149
|
148
|
1 => '下架',
|
|
150
|
149
|
})
|
|
151
|
|
- ->color(fn ($record) => match ($record->visible) {
|
|
|
150
|
+ ->color(fn($record) => match ($record->visible) {
|
|
152
|
151
|
0 => 'warning',
|
|
153
|
152
|
1 => 'gray',
|
|
154
|
153
|
})
|
|
155
|
|
- ->icon(fn ($record) => match ($record->visible) {
|
|
|
154
|
+ ->icon(fn($record) => match ($record->visible) {
|
|
156
|
155
|
0 => 'heroicon-m-chevron-double-up',
|
|
157
|
156
|
1 => 'heroicon-m-chevron-double-down',
|
|
158
|
157
|
})
|
|
159
|
158
|
->action(function ($record) {
|
|
160
|
|
- $record->visible = ! $record->visible;
|
|
|
159
|
+ $record->visible = !$record->visible;
|
|
161
|
160
|
$record->save();
|
|
162
|
161
|
})
|
|
163
|
162
|
->outlined()
|
|
|
@@ -168,6 +167,8 @@ class AlbumResource extends Resource
|
|
168
|
167
|
Tables\Actions\DeleteBulkAction::make(),
|
|
169
|
168
|
]),
|
|
170
|
169
|
])
|
|
|
170
|
+ ->reorderable('order')
|
|
|
171
|
+ ->defaultSort('order')
|
|
171
|
172
|
->defaultSort('created_at', 'desc');
|
|
172
|
173
|
}
|
|
173
|
174
|
|