I\'m attempting to compare a users location (Sent via params in the URL) to offers.offer_lat and offers.offer_long (in my DB) by a distance argument (set in miles)
I
Haversine in Laravel works in this way:
Travel::select(
DB::raw("travels.*,
( 6371 * acos( cos( radians($lat) ) *
cos( radians( lat ) )
* cos( radians( lon ) - radians($lng)
) + sin( radians($lat) ) *
sin( radians( lat ) ) )
) AS distance"))
->orderBy('distance', 'asc')
->get();
and you will get a collection of points ordered by distance (nearest first)
Was used travel model with params lat and lng. parameter distance is added by the raw query