spatie / laravel-query-builder

Easily build Eloquent queries from API requests
https://spatie.be/docs/laravel-query-builder
MIT License
4.06k stars 397 forks source link

Reopening #934 for further discussion #971

Open MrAlpha786 opened 1 month ago

MrAlpha786 commented 1 month ago
          Hi, I am facing the same issue and it would be nice to have an alias for nested relations, because I have to query very deeply nested relations sometimes.

I have a solution for this, what if we create a separate AllowedInclude::alias($name, $internalName), that will directly zip the two arguments. Instead of building separate path for every nested relation.

If this is okay with you, I can implement this :)

Originally posted by @MrAlpha786 in https://github.com/spatie/laravel-query-builder/issues/934#issuecomment-2360234186

AlexVanderbist commented 3 weeks ago

Hey @MrAlpha786, I'm happy to look into a better way to handle include aliases. A separate AllowedInclude method is probably the way to go at first. If the new approach works out better than the current relationship method, I'm also happy to swap both of them in a new major version. Just to be more consistent with the way people expect this feature to work. Interested to hear your thoughts!