ideas icon indicating copy to clipboard operation
ideas copied to clipboard

Alias for eager loading

Open Romik90 opened this issue 4 years ago • 10 comments

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?

Romik90 avatar Apr 12 '20 09:04 Romik90

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

leon0399 avatar Sep 20 '20 21:09 leon0399

+1

Lemmings19 avatar Jan 30 '21 10:01 Lemmings19

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

crissi avatar Feb 04 '21 22:02 crissi

+1

PaolaRuby avatar May 27 '21 15:05 PaolaRuby

There have already been pull requests PR #31976

PaolaRuby avatar May 27 '21 15:05 PaolaRuby

+1

fredsal avatar May 27 '21 15:05 fredsal

+1

erikn69 avatar May 28 '21 20:05 erikn69

+1

marezelej avatar Jun 22 '21 13:06 marezelej

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

crissi avatar Jun 22 '21 13:06 crissi

Good luck

fredsal avatar Jun 22 '21 22:06 fredsal