从雄辩关系中获取价格总和
有没有更快的方法在雄辩中进行以下操作,我尝试了工作,但在我的情况下无法实施它
$bCollection=B::where(['user_id' => $user])->get();
foreach($bCollectionas $b){
$total+=$b->b_by_a($condition)->first()['counter'];
}
Is there a quicker way to do the following in eloquent, I tried withSum but couldn't implement it in my case
$bCollection=B::where(['user_id' => $user])->get();
foreach($bCollectionas $b){
$total+=$b->b_by_a($condition)->first()['counter'];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题不清楚。
如果您想获得一些有关系的表格,则需要尝试这样的事情:
The question is not clear.
If you want to get sum of some table which has relation, then you need to try something like this: