PHPackages                             bagusindrayana/laravel-coordinate - 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. bagusindrayana/laravel-coordinate

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

bagusindrayana/laravel-coordinate
=================================

get nearby location from eloquent laravel

0.0.3(4y ago)3020.6k↑18.6%5MITPHP

Since Jul 8Pushed 3y ago1 watchersCompare

[ Source](https://github.com/bagusindrayana/laravel-coordinate)[ Packagist](https://packagist.org/packages/bagusindrayana/laravel-coordinate)[ RSS](/packages/bagusindrayana-laravel-coordinate/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

LARAVEL-COORDINATE
==================

[](#laravel-coordinate)

find data with the closest location based on its coordinates with eloquent laravel

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

[](#installation)

```
composer require bagusindrayana/laravel-coordinate

```

- In Model

```
#use trait
use Bagusindrayana\LaravelCoordinate\Traits\LaravelCoordinate;

class Toko extends Model
{
    use LaravelCoordinate;

    //optional
    public $_latitudeName = "latitude_column"; //default name is latitude
    public $_longitudeName = "longitude_column"; //default name is longitude

    //

}
```

- Using trait

```
    //get data at a distance of 500 meters (0.5KM)
    $tokos = Toko::nearby([
        -0.497493,//latitude
        117.156480//longitude
    ],0.5)->get();

    //using order, remember that the order is always placed at the end of the query
    //get data with a distance of 1 kilometer and sort it from farthest
    $tokos = Toko::nearby([
        -0.497493,//latitude
        117.156480//longitude
    ],1)->farthest()->get();

    //get data with a distance of 1 kilometer and sort it from closest to closest
    $tokos = Toko::nearby([
        -0.497493,//latitude
        117.156480//longitude
    ],1)->closest()->get();

    //add a custom column containing the distance value of each record
    $tokos = Toko::nearby([
        -0.497493,//latitude
        117.156480//longitude
    ],0.5) //0.5 Km
    ->selectDistance(['id','nama_toko'],'_distance') //this function will add a custom column/alias with the name "_distance" which contains the distance value of each record
    ->get();
```

Formula
-------

[](#formula)

I haven't tried how much data it can handle and how fast the calculations are, so here are 3 different formulas you can try

formula paramter/arguments (int)

- 0 = default
- 1 = Spherical Law of Cosines
- 2 = Haversine formula

example :

```
$tokos = Toko::nearby([
        -0.497493,//latitude
        117.156480//longitude
    ],
    0.5,
    1//using Spherical Law of Cosines
)
->get();
```

Scope
-----

[](#scope)

```
nearby(coordinate,radius/distance = 5,formula = 0)

```

```
closest(coordinate,formula = 0)

```

```
farthest(coordinate,formula = 0)

```

```
selectDistance(fieldName,aliasName,formula = 0)

```

```
insideBox(coorinate(2 coordinate))

```

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity44

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

Every ~2 days

Total

3

Last Release

1819d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2289cf54dc78208267d2e3a0d54c4b268f7db0af9befab35cdb1d46a12b4ca0e?d=identicon)[bagusindrayana](/maintainers/bagusindrayana)

---

Top Contributors

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

---

Tags

coordinategeolocationlaravelnearby

### Embed Badge

![Health badge](/badges/bagusindrayana-laravel-coordinate/health.svg)

```
[![Health](https://phpackages.com/badges/bagusindrayana-laravel-coordinate/health.svg)](https://phpackages.com/packages/bagusindrayana-laravel-coordinate)
```

PHPackages © 2026

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