dcasia / nova-inline-morph-to

A Laravel Nova field for displaying morphTo relationship inline.
MIT License
33 stars 15 forks source link

Unable to use relationship on embedded models #1

Closed fntneves closed 5 years ago

fntneves commented 5 years ago

Hello,

Before anything else, thank you for this package.

I am trying to use InlineMorphTo which one of given types of Nova Resource contains a BelongsTo relationship.

For instance, consider the Article Resource example in README:

InlineMorphTo::make('Template')
    ->types([
        \App\Nova\Video::class,
        \App\Nova\Image::class,
        \App\Nova\Text::class,
        \App\Nova\Gallery::class,
]),

If the Gallery resource contains a BelongsTo field that points to an User resource, I get the following error when accessing pages related to the Article resource:

Call to undefined method \App\Nova\Gallery::user()

milewski commented 5 years ago

Hi @fntneves , thanks for reporting this issue,

I did find an issue using belongsTo inside \App\Nova\Gallery::class and fixed on version v0.1.2 however the error I was getting were different from yours \App\Nova\Gallery::user()

Anyways can you check if the new version fixes this issue? if not can you post all the related files so I can further debug it?

milewski commented 5 years ago

Actually, I found issues with all the other relationship types, fixed them all on the latest release. Please reopen if I have missed something thanks!