我是一名 JS 开发人员,但试图用一些 Laravel 帮助我的团队。
我有他的查询如下:
$customers = ShopUser::selectRaw('shop_users.name, shop_users.email, shop_users.unique_id, shop_users.created_at, SUM(orders.total) AS total_spent, MIN(orders.created_at) AS first_purchase, MAX(orders.created_at) AS last_purchase, count(orders.id) AS total_orders') ->leftJoin('orders', 'orders.customer_id', 'shop_users.id') ->groupBy('shop_users.id') ->get();
然后我想把花费超过 1,000 美元unique_id
的这个查询的用户total
放在一个数组中。有没有办法在上面的查询中做到这一点,还是应该在此之后进行单独的迭代来排序?
慕码人2483693
慕盖茨4494581