ideas
ideas copied to clipboard
Alias for eager loading
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
So I have to create two relations with same code inside
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?
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
+1
Duplicate of https://github.com/laravel/ideas/issues/1396
+1
There have already been pull requests PR #31976
+1
+1
+1
there is a pr made recently here: https://github.com/laravel/framework/pull/37656 🙏
Good luck