I know this question has already been asked but in my case I have a frustrating issue which I am would love to find the answer to. essentially when I run the script I am getting A non-numeric value encountered because I am unable to use the value of the row in db table in the equation. please see below:
$auctions = Auction::join('users','auctions.user_id','users.id')
->join('categories','auctions.category_id','categories.id')
->join('sub_catogories','auctions.sub_category_id','sub_catogories.id')
->select(['auctions.id','auctions.title','auctions.slug',
'auctions.description','auctions.image',
'auctions.reserve_price','auctions.auction_status',
'auctions.start_date','auctions.end_date'],
((acos(sin($orig_lat * pi() / 180) * sin(-37.8136 * pi() / 180) + cos($orig_lat * pi() / 180) * cos(-37.8136 * pi() / 180) * cos(($orig_long - '**HOW DO I INSERT users.lat HERE????**') * pi() / 180)) * 180 / pi()) * 60 * 1.1515), 'AS', 'distance')
->where ( 'lat', 'BETWEEN', ($orig_lat - $bounding_distance), 'AND', ($orig_lat + $bounding_distance), 'AND', 'lng', 'BETWEEN', ($orig_long - $bounding_distance), 'AND', ($orig_long + $bounding_distance))
->orderBy('auctions.id','desc')->paginate(PAGINATE_RECORDS);