hmm a bit late, maybe you fixed it already.. it is a little complicated as you said 🙂 but if i get the general idea i think you might be looking for something like this section from the docs.. https://laravel.com/docs/10.x/eloquent-relationships#inline-relationship-existence-queries
#Nested transformers
17 messages · Page 1 of 1 (latest)
well in fairness the word node is throwing me off, i mean in laravel terms what are the models?
for example my interpretation was you have a product type/node and you want sum(product)->size()-> where type/node = A is less than type sizing...which in itself is a little confusing where does sizing come from, well i guess node?
**let me break it down - to see if i'm half right - you want a report?
in the hazmat world I want all products that I have in hazclass/node x % max allowed for hazclass/node x return bool ??
ok so product belongs to node and node has many products?
ah ok so product has many nodes
*belongs to i think your going to say
ok so in my head (sorry its not exact) but product belongs to a node and there are many products in a node that part is clear - but in your case some products have a special type and you only want those....
by type i mean value
Ok I mean I'm not sure this is the way return $this->item($product->node, new NodeTransformer()); i think it should be either an accessor or use hasManyThrough() relation - not seen a lot of initializing classes inside relations like this, it might be I don't fully understand - i thought you wanted all products of node N then a sum of a value on the product grouped by node with bool response but maybe (probably) I'm lost...
I'll give you one thing though if you've not seen it already, for complex things like this you can always fallback on it and pass your request through as many classes as you like - new one for me but on first glace looks like a nice workflow, i will be bringing it in for sure..
++added benefit of able to throw exceptions from each class or just pass though and pass vars down...
oh ok i meant pass request there directly do build collection in class A pass to Class B etc
**not explored the possibilities with pipeline facade yet fully so sorry if I'm wrong there..
Sorry i couldn't help here anyway, hope someone else joins maybe with more ideas...