malhal / Laravel-Geographical

Easily add longitude and latitude columns to your records and use inherited functionality for calculating distances
MIT License
280 stars 49 forks source link

Geofence does not work with pagination #17

Open Ruitjes opened 5 years ago

Ruitjes commented 5 years ago

Laravel Framework 5.8.14 PHP 7.2.11 10.2.10-MariaDB

 $ads = Ads::geofence($json->lat, $json->lon, 0, $distance);
 $ads = $ads->Paginate(25);

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'distance' in 'having clause' (SQL: select count(*) as aggregate fromadshaving distance BETWEEN 0 AND 99999999)

Ruitjes commented 5 years ago

It will work with simplePagination. But its not ideal in my case..

mattiusclay commented 5 years ago

Just to let others know there is a package which allows you to paginate with the "having" clause.

https://github.com/justbetter/laravel-pagination-with-havings