Skip to content

Instantly share code, notes, and snippets.

@hewerthomn
Created February 21, 2016 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hewerthomn/b6c55088d0ff9c28415b to your computer and use it in GitHub Desktop.
Save hewerthomn/b6c55088d0ff9c28415b to your computer and use it in GitHub Desktop.
$latlng = "-8.769926868691913 -63.88429307573199";
$radius = 5000;
$places = Place::where(DB::raw("ST_Distance_Sphere(places.latlng, ST_GeometryFromText('SRID=4326;POINT({latlng})'))"), '<', $radius)
->select('offers.*', DB::raw("ST_Distance_Sphere(places.latlng, ST_GeometryFromText('SRID=4326;POINT({$latlng})')) AS distance"))
->get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment