More elegant way to handle nested relations?
Can someone come up with more elegant solution for handling relations than this? I've modified the examples a bit so that I can customize the selected fields and add filters when calling
withSomething
but it becomes quite verbose and not easy to read. Here's one of my relation helper functions:
And this is how the query ends up looking:
Which looks somewhat ugly given that I need to declare so many nested expression builders. I can't really even give them nice names like banners
, links
since both eb3
and eb4
are query builders related to links
. In this particular instance I could just move the withLinkTranslations
all to withTranslations
, but I'm still interested if someone has more elegant way to do the case above without losing flexibility.1 Reply
Hey 👋
You could write it with builder pattern (probably?), but it would require more work