I'm creating a nearby android application, using laravel 4.1 as my API.
I found this useful tutorial https://developers.google.com/maps/articles/phpsqlsearch_v3 but I can't seem to rewrite the query to work with laravel 4.
How can I use this query in Eloquent
SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 20;
Thank you.
The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:
SELECT
markers.id,
(3959 * acos(cos(radians(37)) * cos(radians(markers.lat)) * cos(radians(markers.lng) - radians(-122)) + sin(radians(37)) * sin(radians(markers.lat)))) AS distance
FROM
markers
HAVING
distance < 25
ORDER BY
distance LIMIT 0,
20