我正在使用Laravel-5.8雄辩的查询,如下所示:
$destination = Trip::select('destination')
->selectRaw('COUNT(*) AS count')
->groupBy('destination')
->orderByDesc('count')
->limit(5)
->get();如何将其包括在上面的查询中?
,其中client_id = $userClientId
发布于 2019-10-03 07:38:55
您可以直接在分组之前或之后使用where。
$destination = Trip::select('destination')
->selectRaw('COUNT(*) AS count')
->where('client_id', $userClientId)
->groupBy('destination')
->orderByDesc('count')
->limit(5)
->get();https://stackoverflow.com/questions/58214254
复制相似问题