这是我的代码,显示所有具有地理位置的结果
$jobs = Job::select(
DB::raw("*, status,
( 6371 * acos( cos( radians(?) ) *
cos( radians( latitude ) )
* cos( radians( longitude ) - radians(?)
) + sin( radians(?) ) *
sin( radians( latitude ) ) )
) AS distance"))
->having("distance", "<", "?")
->setBindings([$service->latitude, $service->longitude, $service->latitude, 30])
->with(['user'])
->orderBy("id", "desc");
$jobs = $jobs->simplePaginate(10);
但是上面的代码无法与下面的“ where”一起使用,并给我一个空数组
$jobs = Job::select(
DB::raw("*, status,
( 6371 * acos( cos( radians(?) ) *
cos( radians( latitude ) )
* cos( radians( longitude ) - radians(?)
) + sin( radians(?) ) *
sin( radians( latitude ) ) )
) AS distance"))
->having("distance", "<", "?")
->setBindings([$service->latitude, $service->longitude, $service->latitude, 30])
->with(['user'])
->where("status", 3) // not working
->orderBy("id", "desc");
$jobs = $jobs->simplePaginate(10);