Skip to content

Commit

Permalink
Adds PostgreSQL scope driver
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamHutchison committed Dec 31, 2019
1 parent 14ecf62 commit 23c1b3d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* [1.0.0](#400---2019-12-02) - Initial release
* [1.1.0](#400---2019-12-05) - Adds ability to force scope driver in config
* [1.1.1](#400---2019-12-31) - Removes default scope driver
* [1.2.0](#400---2019-12-31) - Adds PostgreSQL scope driver
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ Any missing config options will be replaced with the defaults defined in `config
Under the hood, GeoScope uses different drivers to ensure that the distance queries are optimised to the database connection
being used. Scope drivers correspond to the database drivers used by Laravel. GeoScope will automatically detect the database driver being used
by Laravel and choose the correct scope driver for it. Out of the box GeoScope includes a MySQL scope driver
which uses the built in `ST_Distance_Sphere()` function.
which uses `ST_Distance_Sphere()` function and a PostgreSQL scope driver which uses `earth_distance`.

**NOTE: The PostgreSQL driver requires you to have the postgres `earthdistance` module installed which can be done by executing the following SQL**
```sql
create extension if not exists cube;
create extension if not exists earthdistance;
```

#### Creating Custom Scope Drivers
GeoScope allows you to define and register custom scope drivers. To create a custom scope driver create a class that extends
Expand Down
2 changes: 2 additions & 0 deletions src/ScopeDriverFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Netsells\GeoScope\Exceptions\ScopeDriverNotFoundException;
use Netsells\GeoScope\Interfaces\ScopeDriverInterface;
use Netsells\GeoScope\ScopeDrivers\MySQLScopeDriver;
use Netsells\GeoScope\ScopeDrivers\PostgreSQLScopeDriver;

class ScopeDriverFactory
{
Expand All @@ -13,6 +14,7 @@ class ScopeDriverFactory
*/
protected $registeredStrategies = [
'mysql' => MySQLScopeDriver::class,
'pgsql' => PostgreSQLScopeDriver::class,
];

/**
Expand Down

0 comments on commit 23c1b3d

Please sign in to comment.