mardi 11 juillet 2017

Laravel 5 Eloquent query for haversine formula

I have this query

select tbl_container.*, 
       ( 6371 * acos( cos( radians(17.7427643) ) 
              * cos( radians( tbl_locations.latitude ) ) 
              * cos( radians( tbl_locations.longitude ) - radians(83.3277787) ) 
              + sin( radians(17.7427643) ) 
              * sin( radians( tbl_locations.latitude ) ) ) ) AS distance 
from tbl_locations,tbl_container  
where tbl_container.`status` = 1 
and tbl_container.location_id=tbl_locations.id having distance<4 order by distance asc

For this i have two models Containers,Locations

how to write this query to laravel 5 eloquent...



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2v758Xa
via IFTTT

Aucun commentaire:

Enregistrer un commentaire