How to get records between two latitudes and longitudes using Laravel, php

enter image description here

here what I tried to get but it returns empty between 2 given coordinates

function searchListings(){
    $query = Listings::query();
    $sw_lat = request('sw_lat');
    $ne_lat = request('ne_lat');
    $sw_lng = request('sw_lng');
    $ne_lng= request('ne_lng');
    $query->whereBetween('latitude', [$sw_lat, $ne_lat])->whereBetween('longitude', [$sw_lng, $ne_lng]);
    return $query::paginate(5);

Read more here:

Content Attribution

This content was originally published by Ahmad Waqas at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: