laracoft's avatar

SUM in eloquent

SELECT
    tool_id,
    project_id,
    sum(active)
FROM activity
GROUP BY tool_id, project_id

I was able to get this far Activity::select('tool_id', 'project_id', DB::raw('SUM(active) as active')) ->groupBy(['tool_id', 'project_id']) ->get();

Is there a way to write this in eloquent without having to use DB::raw()?

0 likes
2 replies

Please or to participate in this conversation.