@moemenh_ for sure eager loading will be the best solution here
$companies = Company::with(
'owner',
'address',
'companyInfo'
)
->selectRaw(
"id, owner, company_info, address, latitude, longitude,
(6371 * acos( cos( radians(?))
* cos( radians(latitude) )
* cos( radians( longitude ) - radians(?))
+ sin( radians(?) )
* sin( radians(latitude)))) AS distance",
[$requestedCords['latitude'], $requestedCords['longitude'], $requestedCords['latitude']]
)
->having("distance", "<=", $requestedCords['radius'])
->orderBy("distance",'asc')
->offset(0)
->limit(20)
->get();