Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kodyxgen's avatar

FilamentPHP translation on relationship

Hi, I am using filament-spatie-translation package for translations. All is ok if the translation fields are on the same model. But in my case now i have an Article model with generic fields like status, id, parent_id ... and ArticleDescription model where i have name, description ... with the description relationship declared on the Article model.

    public function description(): HasOne
    {
        return $this->hasOne(ArticleDescription::class);
    }

On the ArticleDescription model i have declared the translatable fields and using the HasTranslations trait.

    public array $translatable = [
        'name',
        'description',
        'short_description',
        'meta_description',
        'meta_title',
        'seo_url',
    ];

I am generating a filament resource ArticleResource and for the TextInput i use

TextInput::make('description.name')

If i use the trait

use Filament\Resources\Concerns\Translatable

i am getting an error

Call to undefined method App\Models\Article::getTranslatableAttributes()

and i get this since the spatie trait HasTranslations is declared on the ArticleDescription. Is there a way to achieve the translation if the translation fields are on the ArticleDescription ?

0 likes
0 replies

Please or to participate in this conversation.