i have to problem, i need to search if user is in specific radius. I have two join tables on users, address and search radius...query will received two param lat and log.
$query = Users::query();
$query->with('location', 'serach_area');
$query->whereHas('location', function ($query) use ($latitude, $longitude) {
$query->select('users_locations.latitude as latitude', 'users_locations.longitude as longitude', 'users_locations.user_id', 'search_area.radius s radius')
->selectRaw("(6371 * acos(cos(radians('.$latitude.')) * cos(radians(latitude)) * cos(radians(longitude) - radians('.$longitude.')) sin(radians('.$latitude.')) * sin(radians(latitude)))) as haversine")
->having("haversine", "<", "radius"); });
I can't get search area.radius if I hard coded number, it works perfectly if anyone have any idea please commented
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2BWUlnd
via IFTTT
Aucun commentaire:
Enregistrer un commentaire