Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.6] Allow eager-loading mixed relationships of polymorphic collection #23626

Merged
merged 1 commit into from
Mar 26, 2018

Commits on Mar 24, 2018

  1. Add Eloquent Collection loadMorph()

    Allow nested relations to be eager loaded for
    morphTo() relationships of mixed classes.
    
    e.g.,
    
    class ActivityFeed
    {
        function parentable()
        {
            return $this->morphTo();
        }
    }
    
    $collection = ActivityFeed::with('parentable')
        ->get()
        ->loadMorph('parentable', [
            Event::class => 'calendar',
            Photo::class => 'tags',
            Post::class => ['author', 'commentsCount'],
        ]);
    
    or
    
    $paginator = ActivityFeed::with('parentable')
        ->paginate()
        ->loadMorph('parentable', [
            // etc.
        ]);
    derekmd authored and Derek MacDonald committed Mar 24, 2018
    Configuration menu
    Copy the full SHA
    4367675 View commit details
    Browse the repository at this point in the history