laravel / ideas

Issues board used for Laravel internals discussions.
939 stars 28 forks source link

morphWithCount new eloquent method #2213

Open RedFernLiam opened 4 years ago

RedFernLiam commented 4 years ago

We have ->with(), we have ->withCount() we have ->morphWith() but, we are missing ->morphWithCount().

Implemented something like this:

$morphTo->morphWithCount([
    Screencast::class => 'videos',
]);

I think this would be a great addition as I ran into a situation where I needed it.

ggolda commented 4 years ago

I have the same problem, looks like there is no solution to it right now.

RedFernLiam commented 4 years ago

@ggolda I have currently used $withCount property on the model to temporarily get around this. Be careful because it's used everywhere.