I want to take this SQL query to a query in Laravel Query Builder. It is important that the result be of type Query Builder. Please if you can help me.
SELECT MAX(sub.total) as total, sub.vendedor
FROM
(
SELECT COUNT(id) as total, vendedor
FROM data_reports dr
GROUP BY vendedor
) sub
I have the following but I couldn't go any further.
$data = DB::table('data_reports')
->select(DB::raw('COUNT(id) as total, vendedor'))
->groupBy('vendedor');