PHPackages                             jaejamesdev/laravelcloseto - 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. [Search &amp; Filtering](/categories/search)
4. /
5. jaejamesdev/laravelcloseto

ActiveLibrary[Search &amp; Filtering](/categories/search)

jaejamesdev/laravelcloseto
==========================

A simple package that allows you to get the closest record to a given latitude and longitude.

00PHP

Since Aug 28Pushed 6y ago1 watchersCompare

[ Source](https://github.com/jaejamesdev/laravelcloseto)[ Packagist](https://packagist.org/packages/jaejamesdev/laravelcloseto)[ RSS](/packages/jaejamesdev-laravelcloseto/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel CloseTo
===============

[](#laravel-closeto)

Laravel CloseTo is a cheeky little eloquent scope to get points within a certain radius area from a given latitude or longitude based off of the Haversine formula.

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

[](#installation)

```
$ composer require jaejamesdev/laravelcloseto
```

Usage
-----

[](#usage)

#### Basic Example:

[](#basic-example)

```
YourModel::closeTo($latitude, $longitude, $radiusInMiles);
```

The above example relies on your database having a column called 'latitude' and a column called 'longitude'. Should your database have a naming structure that is different to 'latitude' and 'longitude', no worries at all, you can use the below:

#### Advanced Example:

[](#advanced-example)

```
YourModel::closeTo($latitude, $longitude, $radiusInMiles, $latiudeColumnName, $longitudeColumnName);
```

#### Ordering By Distance:

[](#ordering-by-distance)

If you want to get the closest results within a radius ordered by distance, this plugin can take care of that for you in a very simple way!

```
YourModel::closeTo($latitude, $longitude, $radiusInMiles)->orderBy('distance', 'asc');
```

Todos
-----

[](#todos)

```
- Add in option to convert between miles and kilometers.
- Improve documentation.

```

Issues &amp; Requests
---------------------

[](#issues--requests)

See [the issues section on Github!](https://github.com/jaejamesdev/laravelcloseto/issues)

Follow Me
---------

[](#follow-me)

Why not give me a follow on [twitter?](https://twitter.com/jaejames16)

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0b39b803f372eaf17fe17d717e49513f0c0f7bbb5fad908ef0bd5e330be26f96?d=identicon)[jaejamesdev](/maintainers/jaejamesdev)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/jaejamesdev-laravelcloseto/health.svg)

```
[![Health](https://phpackages.com/badges/jaejamesdev-laravelcloseto/health.svg)](https://phpackages.com/packages/jaejamesdev-laravelcloseto)
```

###  Alternatives

[ruflin/elastica

Elasticsearch Client

2.3k50.4M203](/packages/ruflin-elastica)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15024.3M65](/packages/opensearch-project-opensearch-php)[mailerlite/laravel-elasticsearch

An easy way to use the official PHP ElasticSearch client in your Laravel applications.

934529.3k2](/packages/mailerlite-laravel-elasticsearch)[massive/search-bundle

Massive Search Bundle

721.4M13](/packages/massive-search-bundle)[outl1ne/nova-multiselect-filter

Multiselect filter for Laravel Nova.

45802.7k3](/packages/outl1ne-nova-multiselect-filter)[handcraftedinthealps/zendsearch

a general purpose text search engine written entirely in PHP 5

39921.0k35](/packages/handcraftedinthealps-zendsearch)

PHPackages © 2026

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