Add multilingual support to labor categories (RO/RU/EN)
- Migration: adds name_ro, name_ru, name_en columns; copies name→name_ro; seeds RU and EN translations for all 11 default categories - LaborCategory: label() returns localized name, optionsForSelect() keyed by canonical name (stored in labors.category) with localized label - LaborCategoryResource: 3-column form with RO/RU/EN inputs; table shows all three columns side by side - LaborResource: category select and filter use optionsForSelect() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -42,13 +42,31 @@ class LaborCategoryResource extends Resource
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->label(__('Denumire'))
|
||||
->required()
|
||||
->maxLength(80)
|
||||
->columnSpanFull(),
|
||||
Forms\Components\Section::make(__('Denumire'))
|
||||
->columns(3)
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name_ro')
|
||||
->label(__('Română (RO)'))
|
||||
->required()
|
||||
->maxLength(80)
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function ($state, callable $set, $get) {
|
||||
// Auto-fill canonical name from name_ro
|
||||
if (! $get('name')) {
|
||||
$set('name', $state);
|
||||
}
|
||||
}),
|
||||
Forms\Components\TextInput::make('name_ru')
|
||||
->label(__('Rusă (RU)'))
|
||||
->maxLength(80),
|
||||
Forms\Components\TextInput::make('name_en')
|
||||
->label(__('Engleză (EN)'))
|
||||
->maxLength(80),
|
||||
]),
|
||||
Forms\Components\Hidden::make('name')
|
||||
->dehydrateStateUsing(fn ($state, $get) => $state ?: $get('name_ro')),
|
||||
Forms\Components\TextInput::make('sort_order')
|
||||
->label(__('Ordine'))
|
||||
->label(__('Ordine afișare'))
|
||||
->numeric()
|
||||
->default(0),
|
||||
]);
|
||||
@@ -63,15 +81,16 @@ class LaborCategoryResource extends Resource
|
||||
->sortable()
|
||||
->alignRight()
|
||||
->width(50),
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label(__('Categorie'))
|
||||
Tables\Columns\TextColumn::make('name_ro')
|
||||
->label('RO')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label(__('Modificat'))
|
||||
->dateTime('d.m.Y')
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('name_ru')
|
||||
->label('RU')
|
||||
->placeholder('—'),
|
||||
Tables\Columns\TextColumn::make('name_en')
|
||||
->label('EN')
|
||||
->placeholder('—'),
|
||||
])
|
||||
->defaultSort('sort_order')
|
||||
->reorderable('sort_order')
|
||||
@@ -80,7 +99,6 @@ class LaborCategoryResource extends Resource
|
||||
Actions\DeleteAction::make(),
|
||||
])
|
||||
->bulkActions([]);
|
||||
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
|
||||
Reference in New Issue
Block a user