A problem with spatie laravel translatable in filament v2 - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Sunday, November 26, 2023

A problem with spatie laravel translatable in filament v2

I'm using laravel Filament V2 along with spatie-laravel-translatable-plugin and Filament modular

But i have a problem whenever i change the language dropdown the inputs don't reflect and when i click save , it only saves the last language

like the attached imageenter image description here

attached my filament resource

class BoosterResource extends Resource
{
   use Translatable;

   public static function getTranslatableLocales(): array
   {
       return ['en', 'ar', 'es'];
   }
   protected static ?string $model = Booster::class;

   protected static ?string $navigationIcon = 'heroicon-o-collection';

   public static function form(Form $form): Form
   {
       return $form
           ->schema([
               TextInput::make('name'),
               TextInput::make('description')
           ]);
   }

   public static function table(Table $table): Table
   {
       return $table
           ->columns([
               Tables\Columns\TextColumn::make('id')->sortable(),
               Tables\Columns\TextColumn::make('name.en')->sortable(),
               Tables\Columns\TextColumn::make('name.ar')->sortable(),
               Tables\Columns\TextColumn::make('description.en'),
           ])
           ->filters([
               //
           ])
           ->actions([
               Tables\Actions\EditAction::make(),
           ])
           ->bulkActions([
               Tables\Actions\DeleteBulkAction::make(),
           ]);
   }

   public static function getRelations(): array
   {
       return [
           //
       ];
   }

   public static function getPages(): array
   {
       return [
           'index' => Pages\ListBoosters::route('/'),
           'create' => Pages\CreateBooster::route('/create'),
           'edit' => Pages\EditBooster::route('/{record}/edit'),
       ];
   }
}


source https://stackoverflow.com/questions/77549112/a-problem-with-spatie-laravel-translatable-in-filament-v2

No comments:

Post a Comment