I can not get the first record without using foreach
query = "SELECT *, (SELECT count(*) FROM corridas c WHERE c.motoqueiro = u.id AND (c.status = 0 OR c.status = 1)) as corrida ,distance_between(u.latitude, u.longitude, $lat, $lon) as km FROM (SELECT * FROM motoqueiros WHERE DATE_SUB(NOW(),INTERVAL 8 SECOND) <= data_update) order by km ASC LIMIT 1";
$data = DB::select($query);
$ data [0], error > Undefined offset: 0
toArray, error > Fatal error: Call to a member function toArray () on array
.get, error > Fatal error: Call to a member function get () on array
I have tried to use $ data [0], toArray, .get, first and nothing, somebody help me, vlw!