将mysql查询转换为laravel eloquent?

时间:2016-05-27 06:42:55

标签: php mysql eloquent laravel-5.2

我想从两个表中获取数据,一个是药房,另一个是地址。我可以通过查询来完成,如

SELECT pharmacies.*,
       addresses.*,
       ( 6371 * acos( cos( radians(32.5033801) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(74.49884399999999) ) + sin( radians(32.5033801) ) * sin( radians( lat ) ) ) ) AS distance 
FROM `pharmacies` join 
      addresses on pharmacies.address_id=addresses.address_id 
      HAVING distance < 25 
      ORDER BY distance

我想在laravel eloquent中完全相同的查询。药房与地址有一对一的关系。请帮助我

由于

1 个答案:

答案 0 :(得分:0)

您可以像这样编写查询:

<span data-ng-hide="isEmptyObject(draft)" style="color:green">Your note has been saved.</span>