Translate labels in TextColumn->badge()

I used to have this code in V2:
Tables\Columns\BadgeColumn::make('status')
->getStateUsing(function (Model $record): string {
return $record->status;
})
->label(__('strings.fields.status'))
->icons([
'heroicon-o-x-mark',
'heroicon-o-document' => 'draft',
'heroicon-o-clock' => 'reviewing',
'heroicon-o-check-circle' => 'published',
])
->colors([
'secondary' => 'draft',
'warning' => 'reviewing',
'success' => 'published',
])
->enum([
'draft' => __('strings.statuses.draft'),
'reviewing' => __('strings.statuses.reviewing'),
'published' => __('strings.statuses.published'),
]),
Tables\Columns\BadgeColumn::make('status')
->getStateUsing(function (Model $record): string {
return $record->status;
})
->label(__('strings.fields.status'))
->icons([
'heroicon-o-x-mark',
'heroicon-o-document' => 'draft',
'heroicon-o-clock' => 'reviewing',
'heroicon-o-check-circle' => 'published',
])
->colors([
'secondary' => 'draft',
'warning' => 'reviewing',
'success' => 'published',
])
->enum([
'draft' => __('strings.statuses.draft'),
'reviewing' => __('strings.statuses.reviewing'),
'published' => __('strings.statuses.published'),
]),
Now that the BadgeColumn is deprecated, how can I translate labels as in the example above? There is no enum() method anymore. This is my updated code:
Tables\Columns\TextColumn::make('status')
->label(__('strings.fields.status'))
->badge()
->color(fn (string $state): string => match ($state) {
'draft' => 'secondary',
'reviewing' => 'warning',
'published' => 'success',
})
->icons(['heroicon-o-x-mark',
'heroicon-o-document' => 'draft',
'heroicon-o-clock' => 'reviewing',
'heroicon-o-check-circle' => 'published']),
Tables\Columns\TextColumn::make('status')
->label(__('strings.fields.status'))
->badge()
->color(fn (string $state): string => match ($state) {
'draft' => 'secondary',
'reviewing' => 'warning',
'published' => 'success',
})
->icons(['heroicon-o-x-mark',
'heroicon-o-document' => 'draft',
'heroicon-o-clock' => 'reviewing',
'heroicon-o-check-circle' => 'published']),
3 Replies