calculate distance between two latitude longitude points in laravel code example
Example: laravel count distance lat/longtidue
$lat = 41.118491 // user's latitude
$lng = 25.404509 // user's longitude
SELECT *,
( 6371 * acos( cos( radians($lat) )
* cos( radians( latitude ) )
* cos( radians( longitude ) - radians($lng) ) + sin( radians($lat) )
* sin( radians( latitude ) ) ) )
AS calculated_distance
FROM settings as T
HAVING calculated_distance <= (SELECT distance FROM settings WHERE sid=T.sid)
ORDER BY distance_calc