How can I make a query below with mysql in laravel:
SELECT
gps.positions.id,
gps.positions.protocol,
gps.positions.deviceid,
gps.positions.servertime,
gps.positions.devicetime,
gps.positions.fixtime,
gps.positions.valid,
gps.positions.latitude,
gps.positions.longitude,
gps.positions.altitude,
gps.positions.speed,
gps.positions.course,
gps.positions.address,
gps.positions.attributes,
gps.positions.accuracy,
gps.positions.network,
sing.veiculos.identificacao,
sing.veiculos.id_tipo,
sing.veiculos.descricao,
sing.veiculos.deviceid
FROM gps.positions
LEFT JOIN sing.veiculos ON sing.veiculos.deviceid = gps.positions.id
WHERE gps.positions.devicetime IN ((SELECT MAX(devicetime) FROM positions GROUP BY deviceid));
Thank you in advance and I'm waiting for a light.