orderBy('order')->orderBy('id'); }); } public static function form(Form $form): Form { return $form ->schema([ Section::make("")->schema([ Group::make()->schema([ Group::make()->schema([ Translate::make()->schema(fn (string $locale) => [ TextInput::make('title')->required($locale == 'zh_TW')->maxLength(40)->label("徽章標題") ]) ->locales(["zh_TW", "en"]) ->actions([ app(DeepLService::class)->createTranslationAction("Main", ["title"]) ])->columnSpan(1), ])->columns(2)->columnSpanFull(), Group::make()->schema([ Select::make("reward_year")->label("認證年份")->options(function () { $currentYear = now()->year; $years = []; for ($i = $currentYear - 20; $i <= $currentYear +5; $i++) { $years[$i] = strval($i) . '年'; } return $years; })->columnSpan(1), ])->columns(2)->columnSpanFull(), Group::make()->schema([ FileUpload::make("img_url")->label("圖片")->directory("badge")->columnSpan(1), ])->columnSpanFull(), ])->columns(4)->columnSpanFull(), Group::make()->schema([ Radio::make("visible")->label("顯示/不顯示")->options([1 => "顯示", 0 => "不顯示"])->inline()->default(1) ->columnSpan(2) ])->columns(4)->columnSpanFull(), ]) ]); } public static function table(Table $table): Table { return $table ->columns([ // TextColumn::make("title")->label("徽章標題"), ImageColumn::make('img_url')->label("圖片") ]) ->filters([ // ]) ->actions([ Tables\Actions\EditAction::make(), ]) ->bulkActions([ Tables\Actions\BulkActionGroup::make([ Tables\Actions\DeleteBulkAction::make(), ]), ]); } public static function getRelations(): array { return [ // ]; } public static function getPages(): array { return [ 'index' => Pages\ListBadges::route('/'), 'create' => Pages\CreateBadge::route('/create'), 'edit' => Pages\EditBadge::route('/{record}/edit'), ]; } }