vedatunlu / order-by-distance
This package helps ordering your location model by distance for given coordinates
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/vedatunlu/order-by-distance
Requires
- php: >=8.0
Requires (Dev)
- orchestra/testbench: ^8.0
- phpunit/phpunit: ^10.1
This package is auto-updated.
Last update: 2025-12-21 13:59:56 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.