Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
/bootstrap/compiled.php
/vendor
/node_modules
.idea/workspace.xml
.idea/tasks.xml
.idea/dictionaries
.idea/vcs.xml
.idea/jsLibraryMappings.xml
.idea/dataSources.ids
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml
.idea/gradle.xml
.idea/libraries
.idea/mongoSettings.xml
.idea/
*.iws
/out/
.idea_modules/
Expand Down
107 changes: 0 additions & 107 deletions .idea/laravel-spatial.iml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

51 changes: 0 additions & 51 deletions .idea/php.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/vagrant.xml

This file was deleted.

62 changes: 52 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# Laravel Spatial extension

This package is fully untested, undocumented and unstable and is a combination of the two great packages:
- [Laravel PostGIS extension](https://github.com/njbarrett/laravel-postgis)
- [Laravel MySQL spatial extension](https://github.com/grimzy/laravel-mysql-spatial)

- [Laravel PostGIS extension](https://github.com/njbarrett/laravel-postgis)
- [Laravel MySQL spatial extension](https://github.com/grimzy/laravel-mysql-spatial)

## Installation

Installation made super-easy with [composer](https://getcomposer.org):
```

```bash
composer require apptimists/laravel-spatial
```

Expand All @@ -21,16 +23,56 @@ If you try using it on a shared host which is not fulfilling those requirements,

## Usage

We use the [GeoJson PHP Library](http://jmikola.github.io/geojson/) for describing spatial fields as GeoJSON object, e.g.:
### Migrations

Add spatial fields to your migrations the same way you would any others:

```php
$table->point('point_column');
$table->linestring('line_string_column');
$table->polygon('polygon_column');
$table->geometry('geometry_column');

$table->multipoint('multi_point_column');
$table->multilinestring('multi_line_string_column');
$table->multipolygon('multi_polygon_column');
$table->geometrycollection('geometry_collection_column');
```

### Models

Any models that use spatial fields need to use the `LaravelSpatial\Eloquent\SpatialTrait`, and list the spatial fields themselves in the `$spatialFields` property:

```php
use LaravelSpatial\Eloquent\SpatialTrait;

// ...

class MyModel extends Model
{
use SpatialTrait;

// ...

protected $spatialFields = ['location'];

// ...
}
```

### Values

We use the [GeoJson PHP Library](http://jmikola.github.io/geojson/) for describing spatial fields as GeoJSON object, e.g.:

```php
use GeoJSON\Geometry\Point;
...

// ...

$eloquent = new MyModel();
$eloquent->location = new Point([49.7, 6.9]);
...

// ...

$eloquent->save();
```