vedatunlu / order-by-distance
This package helps ordering your location model by distance for given coordinates
v1.0.0
2023-06-09 13:16 UTC
Requires
- php: >=8.0
Requires (Dev)
- orchestra/testbench: ^8.0
- phpunit/phpunit: ^10.1
This package is auto-updated.
Last update: 2024-10-21 11:34:50 UTC
README
Order By Distance
This package provides an elegant way to sort your model collection by distance.
Installation
- Use Composer to add the package to your project:
composer require vedatunlu/order-by-distance
- Add NearestTo trait to the model you want to use in your laravel project.
Important: Your model should have 'latitude' and 'longitude' columns on the database.
Basic Usage
Location::nearestTo(41.02488721726937, 29.015275681371868) ->get(); Location::where('title', $title) ->nearestTo(41.02488721726937, 29.015275681371868) ->get();
Contributing to the package
We welcome and appreciate your contributions to the package! The contribution guide can be found here.
License
This package is open-sourced software licensed under the MIT license.