1
I’m trying to run a query on Laravel
, in the terminal works perfectly, but when I insert in the Laravel
, the same returns me empty, example:
Consultation:
SELECT
MAX(positions.id),
devices.name,
positions.deviceid,
positions.servertime,
positions.devicetime,
positions.fixtime,
positions.latitude,
positions.longitude
FROM positions
INNER JOIN devices
ON positions.deviceid = devices.id
GROUP BY positions.deviceid
in the Laravel
:
$ultimasPosicoes = PositionAll::select('SELECT
MAX(positions.id),
devices.name,
positions.deviceid,
positions.servertime,
positions.devicetime,
positions.fixtime,
positions.latitude,
positions.longitude
FROM
positions
INNER JOIN devices ON positions.deviceid = devices.id
GROUP BY
positions.deviceid');
just a hint, put your model name in the singular, and leave a name that indicates your role. Ex:
Position.php
– Leandro RR