Извините за этот вопрос новичка, я не знаю, как преобразовать этот запрос mysql в конструктор запросов laravel, пожалуйста, проверьте мой запрос sql. Заранее спасибо, ребята
SELECT vehicle_monitoring.id AS monitoring_id,
Sum(vehicle_monitoring_details.distance_travelled) AS total_distance,
Sum(CASE
WHEN vehicle_monitoring_details.purpose = 'Business' THEN
vehicle_monitoring_details.distance_travelled
END) AS distance_business,
Sum(CASE
WHEN vehicle_monitoring_details.purpose = 'Private' THEN
vehicle_monitoring_details.distance_travelled
END) AS distance_private
FROM vehicle_monitoring
JOIN vehicle_monitoring_details
ON vehicle_monitoring_details.vehicle_monitoring_id =
vehicle_monitoring.id
GROUP BY vehicle_monitoring.id