Laravel 拉威尔雄辩的质疑+;哈弗森距离计算器

Laravel 拉威尔雄辩的质疑+;哈弗森距离计算器,laravel,Laravel,我写了这个查询,但它在抱怨 语法错误,意外的'->'(T_OBJECT_运算符) 在HAVING语句开始的地方,因此它必须是上面的某个撇号或分号。我已经尝试了几种组合方法来编写关于括号数的别名(作为距离),以便将错误向下移动 以下是查询: $properties = DB::table('properties') ->join('addresses', 'properties.id_address_fk', '=', 'addresses.id')

我写了这个查询,但它在抱怨 语法错误,意外的'->'(T_OBJECT_运算符)

在HAVING语句开始的地方,因此它必须是上面的某个撇号或分号。我已经尝试了几种组合方法来编写关于括号数的别名(作为距离),以便将错误向下移动

以下是查询:

 $properties  = DB::table('properties')
            ->join('addresses', 'properties.id_address_fk', '=', 'addresses.id')
            ->select('properties.id', 'title', 'city', 'price', 'postedat',
                 ( '3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) )
                       + sin( radians(37) ) * sin( radians( lat ) ) ) as distance') );


            if (!empty($location)) {
            $properties = $properties->where('location', '=', $location);
            }

             if (!empty($propertytype)) {
            $properties = $properties->where('propertytype', '=', $propertytype);
            }

             if (!empty($bedrooms)) {
            $properties = $properties->where('bedrooms', '>=', $bedrooms);
            }

             if (!empty($transaction)) {
            $properties = $properties->where('transaction', '=', $transaction);
            }

             if (!empty($minprice)) {
            $properties = $properties->where('price', '>=', $minprice);
            }

             if (!empty($maxprice)) {
            $properties = $properties->where('price', '<=', $maxprice);
            }


            ->having('distance', '<', $radius)
            ->orderBy('distance', 'desc')
            ->skip(10)
            ->take(5)
            ->get();
$properties=DB::table('properties')
->join('addresses'、'properties.id\u address\u fk'、'='、'addresses.id')
->选择('properties.id'、'title'、'city'、'price'、'postedat',
('3959*acos(弧度(37))*cos(弧度(纬度))*cos(弧度(lng)-弧度(-122))
+sin(弧度(37))*sin(弧度(纬度))表示距离');
如果(!空($location)){
$properties=$properties->where('location','=',$location);
}
如果(!empty($propertytype)){
$properties=$properties->where('propertytype','=',$propertytype);
}
如果(!空($卧室)){
$properties=$properties->where('beddrooms','>=',$beddrooms);
}
如果(!空($transaction)){
$properties=$properties->where('transaction','=',$transaction);
}
如果(!空($minprice)){
$properties=$properties->where('price','>=',$minprice);
}
如果(!空($maxprice)){

$properties=$properties->where('price','您必须使用查询对象:


$properties->having('distance','correct!谢谢!我非常感激并感到有点害怕,有人以70k+回答了我,谢谢你无数次,祝你度过最美好的时光。