May 10, 2022
0
Level 1
Run query WithSum() for sub Withsum()'s result
User::where('id', 1)->withSum(['descendants' => function($query) { return $query->whereDepth('<', 10)->depthFirst()->withSum('nfts', 'price'); }],'nfts_sum_price')->first();
I'm trying to withsum() inside other withsum's results. When I try just sum id it works. But i need sum of ->withSum('nfts', 'price') this method what returns. I take "Undefined column" error.
Is it possible for to sum like that in 1 query? And how I do it?
Please or to participate in this conversation.