PHPackages                             vedatunlu/order-by-distance - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vedatunlu/order-by-distance

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vedatunlu/order-by-distance
===========================

This package helps ordering your location model by distance for given coordinates

v1.0.0(2y ago)07MITPHPPHP &gt;=8.0

Since Jun 9Pushed 2y ago1 watchersCompare

[ Source](https://github.com/vedatunlu/order-by-distance)[ Packagist](https://packagist.org/packages/vedatunlu/order-by-distance)[ RSS](/packages/vedatunlu-order-by-distance/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

 [![](https://camo.githubusercontent.com/8ee0dab5df34bdc6a0d40e46abc673c2d9b26035fb3e899620abd6a22889a545/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7665646174756e6c752f6f726465722d62792d64697374616e6365)](https://camo.githubusercontent.com/8ee0dab5df34bdc6a0d40e46abc673c2d9b26035fb3e899620abd6a22889a545/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7665646174756e6c752f6f726465722d62792d64697374616e6365) [![](https://camo.githubusercontent.com/852926b7d427b5dd6de812df996231b5ec9df7c92574c5627f0468e05bfa82b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f7665646174756e6c752f6f726465722d62792d64697374616e6365)](https://camo.githubusercontent.com/852926b7d427b5dd6de812df996231b5ec9df7c92574c5627f0468e05bfa82b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f7665646174756e6c752f6f726465722d62792d64697374616e6365) [![](https://camo.githubusercontent.com/ca17c955f0c1dd3e9445afd3f64d7fa202df20aca9c39e77d4a93605f29045b4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f7665646174756e6c752f6f726465722d62792d64697374616e6365)](https://camo.githubusercontent.com/ca17c955f0c1dd3e9445afd3f64d7fa202df20aca9c39e77d4a93605f29045b4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f7665646174756e6c752f6f726465722d62792d64697374616e6365) [![](https://camo.githubusercontent.com/46848a78ce4b57def0d0aa73dbe66d583a34ebc17715d6b8b3b714f1320a0b00/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f7665646174756e6c752f6f726465722d62792d64697374616e6365)](https://camo.githubusercontent.com/46848a78ce4b57def0d0aa73dbe66d583a34ebc17715d6b8b3b714f1320a0b00/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f7665646174756e6c752f6f726465722d62792d64697374616e6365) [![](https://camo.githubusercontent.com/809bd8014785dc33ad5767e5de86908cff56307836e105a8698d5f2d38ec8b2f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652d646174652f7665646174756e6c752f6f726465722d62792d64697374616e6365)](https://camo.githubusercontent.com/809bd8014785dc33ad5767e5de86908cff56307836e105a8698d5f2d38ec8b2f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652d646174652f7665646174756e6c752f6f726465722d62792d64697374616e6365) [![](https://camo.githubusercontent.com/3ef3a60905856fc0db0e8019fad3d2d1e8cc4691d54cc38e42205735dfa9db15/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e63652d4d49542d677265656e)](https://camo.githubusercontent.com/3ef3a60905856fc0db0e8019fad3d2d1e8cc4691d54cc38e42205735dfa9db15/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e63652d4d49542d677265656e)

Order By Distance
=================

[](#order-by-distance)

This package provides an elegant way to sort your model collection by distance.

Installation
------------

[](#installation)

1. Use Composer to add the package to your project:

```
    composer require vedatunlu/order-by-distance
```

2. 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
===========

[](#basic-usage)

```
    Location::nearestTo(41.02488721726937, 29.015275681371868)
        ->get();

    Location::where('title', $title)
        ->nearestTo(41.02488721726937, 29.015275681371868)
        ->get();
```

Contributing to the package
===========================

[](#contributing-to-the-package)

We welcome and appreciate your contributions to the package! The contribution guide can be found [here](https://github.com/vedatunlu/order-by-distance/blob/master/CONTRIBUTE.md).

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](https://github.com/vedatunlu/order-by-distance/blob/master/LICENSE).

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1068d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e363b0b4dbfeaea4caec59082afad6ea8f04b9eadacebcc333c3e1c337c37f45?d=identicon)[vedatunlu](/maintainers/vedatunlu)

---

Top Contributors

[![vedatunlu](https://avatars.githubusercontent.com/u/49617126?v=4)](https://github.com/vedatunlu "vedatunlu (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vedatunlu-order-by-distance/health.svg)

```
[![Health](https://phpackages.com/badges/vedatunlu-order-by-distance/health.svg)](https://phpackages.com/packages/vedatunlu-order-by-distance)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
