Skip to content

Commit 23c1b3d

Browse files
committed
Adds PostgreSQL scope driver
1 parent 14ecf62 commit 23c1b3d

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1414
* [1.0.0](#400---2019-12-02) - Initial release
1515
* [1.1.0](#400---2019-12-05) - Adds ability to force scope driver in config
1616
* [1.1.1](#400---2019-12-31) - Removes default scope driver
17+
* [1.2.0](#400---2019-12-31) - Adds PostgreSQL scope driver

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,13 @@ Any missing config options will be replaced with the defaults defined in `config
117117
Under the hood, GeoScope uses different drivers to ensure that the distance queries are optimised to the database connection
118118
being used. Scope drivers correspond to the database drivers used by Laravel. GeoScope will automatically detect the database driver being used
119119
by Laravel and choose the correct scope driver for it. Out of the box GeoScope includes a MySQL scope driver
120-
which uses the built in `ST_Distance_Sphere()` function.
120+
which uses `ST_Distance_Sphere()` function and a PostgreSQL scope driver which uses `earth_distance`.
121+
122+
**NOTE: The PostgreSQL driver requires you to have the postgres `earthdistance` module installed which can be done by executing the following SQL**
123+
```sql
124+
create extension if not exists cube;
125+
create extension if not exists earthdistance;
126+
```
121127

122128
#### Creating Custom Scope Drivers
123129
GeoScope allows you to define and register custom scope drivers. To create a custom scope driver create a class that extends

src/ScopeDriverFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Netsells\GeoScope\Exceptions\ScopeDriverNotFoundException;
66
use Netsells\GeoScope\Interfaces\ScopeDriverInterface;
77
use Netsells\GeoScope\ScopeDrivers\MySQLScopeDriver;
8+
use Netsells\GeoScope\ScopeDrivers\PostgreSQLScopeDriver;
89

910
class ScopeDriverFactory
1011
{
@@ -13,6 +14,7 @@ class ScopeDriverFactory
1314
*/
1415
protected $registeredStrategies = [
1516
'mysql' => MySQLScopeDriver::class,
17+
'pgsql' => PostgreSQLScopeDriver::class,
1618
];
1719

1820
/**

0 commit comments

Comments
 (0)