PHPackages                             laralabs/geo-sorter - 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. laralabs/geo-sorter

ActiveLibrary

laralabs/geo-sorter
===================

Postcode distance sorting package for Laravel Collections.

3.1.0(1y ago)12.1k2MITPHPPHP ^8.1

Since Mar 17Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Laralabs/geo-sorter)[ Packagist](https://packagist.org/packages/laralabs/geo-sorter)[ RSS](/packages/laralabs-geo-sorter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (17)Used By (0)

Geo Sorter for Laravel
======================

[](#geo-sorter-for-laravel)

Postcode distance sorting package for Laravel Collections.

**UNITED KINGDOM POSTCODES ONLY**

🚀 Quick Start
-------------

[](#rocket-quick-start)

### Installation

[](#installation)

Require the package in the `composer.json` of your project.

```
composer require laralabs/geo-sorter

```

Publish the configuration file.

```
php artisan vendor:publish --tag=geosorter-config

```

Edit the configuration file and set your desired settings. If you want to use a custom database table name, set it here and cache your config before moving onto the next step.

Create the postcodes table by running the following command:

```
php artisan migrate

```

Once the database table has been created, run the following command to populate it with the latest UK Postcode District data.

```
php artisan geosorter:update

```

### Usage

[](#usage)

A helper function and facade are available, choose your preferred method. The `sortByPostcode` method accepts three arguments, the third argument being an optional `$sort` which can be used to override the sort order defined in the config.

Facade:

```
