查询当天销售额最多的 3 个用户

Query for getting the 3 users with most sales of the day

我需要从数据库中检索销售额最高的前 3 名用户。我有这个查询:

Order::select(DB::raw('sum(total_wholesale) as sums'))        
        ->whereDate('created_at', Carbon::today())
        ->orderBy('sums','DESC')        
        ->take(3)
        ->with('seller')
        ->get();

但只是returns没有卖家关系的金额。关于如何获得这样的东西的任何想法:

user1 todays sum
user2 todays sum
user3 todays sum

当然是一个非常简单的解决方案。我在 select 语句中遗漏了 seller_id 来使 with('seller') 关系起作用:

Order::select('seller_id', DB::raw('sum(total_wholesale) as sums'))        
        ->whereDate('created_at', Carbon::today())
        ->orderBy('sums','DESC')        
        ->take(3)
        ->groupBy('seller_id')
        ->with('seller')
        ->get();