morphTo relationship

In model public function image(){ return $this->morphTo(Image::class, 'imageable')->where('position_slug', 'logo'); } in filament resources Fieldset::make('Metadata') ->relationship('image') ->schema([ FileUpload::make('image')->image(), ]) but it's not uploading image in relationship model. and my relational table is in given screenshot.
3 Replies
botaviator1990
botaviator1990OP17mo ago
Patrick Boivin
Patrick Boivin17mo ago
I think it needs to be morphOne() on the parent model and morphTo() on the Image : https://laravel.com/docs/10.x/eloquent-relationships#one-to-one-polymorphic-model-structure
botaviator1990
botaviator1990OP17mo ago
Thank you, this is working for me
Want results from more Discord servers?
Add your server