Skip to content

Eager Loading Polymorphic Relation's Related Models #6368

Closed
@MovingGifts

Description

@MovingGifts

Hi @taylorotwell,

I can eager load polymorphic relations/models without any n+1 issues. However, if I try to access a model related to the polymorphic model, the n+1 problem appears and I can't seem to find a fix.

Here is an easily reproducible example I put together: http://stackoverflow.com/questions/26727088/laravel-eager-loading-polymorphic-relations-related-models/26825205#26825205

I am sure the laravel community would love to be able to eager load those polymorphic models related models using the same familiar syntax as this: $histories = History::with('historable.company')->get(); where company is a polymorphic models related model.

For now, I went with the accepted stack overflow answer since calling it like that was not possible.

Please let us know your thoughts on this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions