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
botaviator1990OP2y ago
Patrick Boivin
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
botaviator1990OP2y ago
Thank you, this is working for me

Did you find this page helpful?