laravel - 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');
但这不能正常工作,有什么建议吗?
解决方案
我需要做的就是将其更改为 whereIn。
$managerAccounts = Account::where('manager_id', auth()->id())->get('id');
return $this->count($request, Subscription::whereIn('account_id', $managerAccounts), 'quantity');
推荐阅读
- java - 由 servlet 生成的单击操作按钮 HTML
- javascript - PhantomJS/CasperJS 客户端使用
- python - TypeError:'float'对象在 scipy 最小化期间不可下标
- javascript - 使用 Javascript 对带有日期范围列的 HTML 表进行排序
- angular - Angular 在 DI 树中查找路由
- jenkins - Jenkins管道如何更改到另一个文件夹
- laravel - 如何允许 Laravel 管理员用户模拟或验证我网站上的任何其他用户?
- bash - 从 ssh 到远程的本地执行 rsync 并复制到辅助远程
- ruby - 了解 Ruby 何时将字符串更改为 Unicode 表示
- angular - Angular 6 Datatable 行标题?