首页 > 解决方案 > Laravel Nova Metrics 值,复杂计算

问题描述

我必须遵循模型。Manager(id,name,...) Account(id,manager_id,...) 订阅(id,account_id,quantity,...)

我想获取与在线经理关联的所有帐户的所有订阅。

我尝试过这样的事情。

$managerAccounts = Account::where('manager_id', auth()->id())->get('id');

return $this->count($request, Subscription::where('account_id', $managerAccounts), 'quantity');

但这不能正常工作,有什么建议吗?

标签: laravelmetricslaravel-nova

解决方案


我需要做的就是将其更改为 whereIn。

$managerAccounts = Account::where('manager_id', auth()->id())->get('id');

return $this->count($request, Subscription::whereIn('account_id', $managerAccounts), 'quantity');


推荐阅读