laravel / ideas

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

Alias for eager loading #2183

Open Romik90 opened 4 years ago

Romik90 commented 4 years ago

Hi. My problem is that I need something like an alias for eager loading in case when I use same relation. For example imagine if I have cms with leads. Every lead has the responsible manager. I wanna get analytics of managers with different constrains This code doesn't work image

So I have to create two relations with same code inside image

Maybe I'll need to have another request to the same Lead model so I need to create one more method with the same logic inside. What could be an alternative solution?

leon0399 commented 4 years ago

Totally agreed! Such behaviour already exists for relationships counts, and just have to exist on relationships themselves

https://laravel.com/docs/8.x/eloquent-relationships#counting-related-models

Lemmings19 commented 3 years ago

+1

crissi commented 3 years ago

Duplicate of https://github.com/laravel/ideas/issues/1396

PaolaRuby commented 3 years ago

+1

PaolaRuby commented 3 years ago

There have already been pull requests PR #31976

fredsal commented 3 years ago

+1

erikn69 commented 3 years ago

+1

marezelej commented 3 years ago

+1

crissi commented 3 years ago

there is a pr made recently here: https://github.com/laravel/framework/pull/37656 🙏

fredsal commented 3 years ago

Good luck