schema([ Forms\Components\TextInput::make('group') ->required() ->maxLength(255) ->default('storefront') ->helperText('Namespace for this label, e.g. "storefront" for e-shop UI text.'), Forms\Components\TextInput::make('key') ->required() ->maxLength(255) ->helperText('Dot-notation key, e.g. "nav.cart".'), Forms\Components\Fieldset::make('Translations') ->schema(static::localeInputs()), ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('group') ->badge() ->sortable(), Tables\Columns\TextColumn::make('key') ->searchable() ->sortable(), ...static::localeColumns(), ]) ->filters([ Tables\Filters\SelectFilter::make('group') ->options(fn () => LanguageLine::query()->distinct()->pluck('group', 'group')), ]) ->defaultSort('key'); } public static function getRelations(): array { return []; } public static function getPages(): array { return [ 'index' => Pages\ListLanguageLines::route('/'), 'create' => Pages\CreateLanguageLine::route('/create'), 'edit' => Pages\EditLanguageLine::route('/{record}/edit'), ]; } /** * @return array */ private static function localeInputs(): array { return static::localeCodes() ->map(fn (string $code) => Forms\Components\Textarea::make("text.{$code}") ->label(strtoupper($code)) ->rows(2)) ->all(); } /** * @return array */ private static function localeColumns(): array { return static::localeCodes() ->map(fn (string $code) => Tables\Columns\TextColumn::make("text.{$code}") ->label(strtoupper($code)) ->limit(40) ->toggleable()) ->all(); } private static function localeCodes(): \Illuminate\Support\Collection { return Language::query()->pluck('code'); } }