Spatie Translatable Plugin and relationship fieldset

My Page model has a MorphOne relationship to the Seo model. The Seo model has columns like title and description. In my PageResource i have a fieldset for the Seo relationship:
Forms\Components\Fieldset::make('seo')
->relationship(name: 'seo')
->schema([
Forms\Components\TextInput::make('title')
->label(__('SEO title'))
->string(),

Forms\Components\Textarea::make('description')
->label(__('SEO description'))
->string(),
]),
Forms\Components\Fieldset::make('seo')
->relationship(name: 'seo')
->schema([
Forms\Components\TextInput::make('title')
->label(__('SEO title'))
->string(),

Forms\Components\Textarea::make('description')
->label(__('SEO description'))
->string(),
]),
This works just fine. Until i add the Spatie Translatable Plugin. I found out adding the relationship name to the translatable array on the page model made the language selector "work" on the related textInputs: public array $translatable = ['title', 'seo']; Now when i switch languages using the LocaleSwitcher on the create or edit screen, the inputs seem to store the data per language. When i enter just 1 language, no issue, but when i set multiple language variables and save it, i get an error
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'seo' in 'field list'
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'seo' in 'field list'
Now all of a sudden the seo isn't stored as a relationship but as a column on the page model. the raw query is: update pages set title = ?, seo = ?, pages.updated_at = ? where id = ? Any ideas would be welcome
3 Replies
Ankit Thapa
Ankit Thapa7mo ago
Did you manage to solve this I am also getting this problem ?
awcodes
awcodes7mo ago
You can’t define Seo as translatable on the parent model. You need to set it to have its own translations on the Seo model. If I’m understanding your setup correctly.
RobinDev
RobinDev6mo ago
Im having the same issue, it worked before but not anymore
Want results from more Discord servers?
Add your server