PHPackages                             netsells/laravel-geoscope - 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. netsells/laravel-geoscope

AbandonedArchivedLibrary

netsells/laravel-geoscope
=========================

GeoScope is a laravel package that allows you to easily perform distance queries and geofencing based on latitudes and longitudes.

2.0.2(5y ago)1030.4k↓20%7[1 issues](https://github.com/netsells/laravel-geoscope/issues)MITPHPPHP &gt;=7.2CI failing

Since Dec 2Pushed 5y ago2 watchersCompare

[ Source](https://github.com/netsells/laravel-geoscope)[ Packagist](https://packagist.org/packages/netsells/laravel-geoscope)[ RSS](/packages/netsells-laravel-geoscope/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (19)Used By (0)

Laravel GeoScope
================

[](#laravel-geoscope)

GeoScope is a laravel package that allows you to easily perform distance queries and geofencing based on latitudes and longitudes.

It is created and maintained by the [Netsells team](https://netsells.co.uk/)

Key Features
------------

[](#key-features)

- Supports Laravel 5.3 and above
- Find all records within a given distance of a set latitude and longitude using either the model trait or the DB query builder.
- Can automatically order results by distance from the given lat and long.
- Can be fully configured to work with multiple lat long columns on a single model / table.
- Uses native database functions for the fastest possible performance - no more slow haversine queries.
- Supports MySql, Mariadb, Postgres and SQLServer out of the box.
- Can be set to automatically add `distance` and `distance_units` fields to model results.
- Distance units are completely configurable.

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

[](#installation)

using composer:

```
$ composer require netsells/laravel-geoscope

```

Then publish the config file using the following artisan command:

```
php artisan vendor:publish --tag=geoscope

```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

GeoScope includes the `Netsells\GeoScope\Traits\GeoScopeTrait` that can be added to your models. The trait contains two scopes, `withinDistanceOf` and `orWithinDistanceOf`. `withinDistanceOf` will add a `where` clause to your query and `orWithinDistanceOf`will add an `orWhere`. Both of these methods accept 3 parameters, a latitude, longitude and distance. Both the latitude and longitude should be given in degrees. GeoScope with then use these to query against the specified lat long fields on that model.

```
