schema([ Section::make("")->schema([ Select::make("selected_year")->label("年份")->options(function () { $currentYear = now()->year; $years = []; // 從 10 年前到 5 年後 for ($i = $currentYear - 10; $i <= $currentYear; $i++) { $years[$i] = strval($i) . '年'; } return $years; })->columnSpan(1), Select::make("selected_month")->label("月份")->options(function (){ $months = []; for($i=1;$i<=12 ;$i++){ $months[$i] = strval($i) . "月"; } return $months; })->default(now()->month)->columnSpan(1), Translate::make()->schema(fn (string $locale) => [ TextInput::make('title')->required($locale == 'zh_TW')->label("標題"), Textarea::make('description')->required($locale == 'zh_TW')->label("內文"), ]) ->locales(["zh_TW", "en"]) ->actions([ app(DeepLService::class)->createTranslationAction("Main", ["title"]) ])->columnSpanFull(), Radio::make("visible")->label("顯示/不顯示")->options([1 => "顯示", 0 => "不顯示"])->inline()->default(1)->columnSpan(2) ])->columns(3) ]); } public static function table(Table $table): Table { return $table ->columns([ TextColumn::make("selected_year")->label("年份")->alignCenter(), TextColumn::make("selected_month")->label("月份")->alignCenter(), TextColumn::make("title")->label("標題"), ]) ->filters([ SelectFilter::make('selected_year')->label("年份") ->options(function () { $currentYear = now()->year; $years = []; // 從 10 年前到 5 年後 for ($i = $currentYear - 10; $i <= $currentYear + 10; $i++) { $years[$i] = strval($i) . '年'; } return $years; }) ->attribute('selected_year'), SelectFilter::make('selected_month')->label("月份") ->options(function () { $months = []; for($i=1;$i<=12 ;$i++){ $months[$i] = strval($i) . "月"; } return $months; }) ->attribute('selected_month'), ]) ->actions([ Tables\Actions\EditAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), ]), ]) ->modifyQueryUsing(function (Builder $query) { // ✅ 正確:多欄位排序 return $query ->orderBy('selected_year', 'desc') ->orderBy('selected_month', 'desc'); }); } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => Pages\ListEgsHistories::route('/'), 'create' => Pages\CreateEgsHistory::route('/create'), 'edit' => Pages\EditEgsHistory::route('/{record}/edit'), ]; } }