Skip to content

Commit

Permalink
readme fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MatanYadaev committed Feb 24, 2024
1 parent dbebd7d commit 16a979f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ composer require matanyadaev/laravel-eloquent-spatial
}
```
* On Postgres, Laravel create spatial columns as `geography` type by default. If you want to use `geometry` type, you can use the `->isGeometry()` method:
```php
$table->point('location')->isGeometry()->nullable();
$table->polygon('area')->isGeometry()->nullable();
```
You can also use the `->projection()` method to set the SRID:
```php
$table->point('location')->projection(Srid::WGS84->value)->nullable(); // 4326 is the default of `geography` type
$table->polygon('area')->isGeometry()->projection(0)->nullable(); // 0 is the default of `geometry` type
```
3. Run the migration:
```bash
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
restart: unless-stopped
postgres:
container_name: postgres-laravel-eloquent-spatial
image: postgis/postgis:16-2
image: postgis/postgis:16-3.4
environment:
POSTGRES_DB: laravel_eloquent_spatial_test
POSTGRES_USER: root
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ parameters:
- src/Factory.php
ignoreErrors:
-
message: '#Call to an undefined method Illuminate\\Database\\Schema\\ColumnDefinition\:\:(isGeometry|projection)\(\)#'
message: '#Call to an undefined method Illuminate\\Database\\Schema\\ColumnDefinition\:\:isGeometry\(\)#'
path: tests/database/migrations/*.php
-
message: '#Undefined variable: \$this#'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ public function up(): void
$table->timestamps();
$table->string('name');
$table->string('address');
$table->point('point')->isGeometry()->projection(0)->nullable();
$table->multiPoint('multi_point')->isGeometry()->projection(0)->nullable();
$table->lineString('line_string')->isGeometry()->projection(0)->nullable();
$table->multiLineString('multi_line_string')->isGeometry()->projection(0)->nullable();
$table->polygon('polygon')->isGeometry()->projection(0)->nullable();
$table->multiPolygon('multi_polygon')->isGeometry()->projection(0)->nullable();
$table->geometryCollection('geometry_collection')->isGeometry()->projection(0)->nullable();
$table->point('point_with_line_string_cast')->isGeometry()->projection(0)->nullable();
$table->point('point')->isGeometry()->nullable();
$table->multiPoint('multi_point')->isGeometry()->nullable();
$table->lineString('line_string')->isGeometry()->nullable();
$table->multiLineString('multi_line_string')->isGeometry()->nullable();
$table->polygon('polygon')->isGeometry()->nullable();
$table->multiPolygon('multi_polygon')->isGeometry()->nullable();
$table->geometryCollection('geometry_collection')->isGeometry()->nullable();
$table->point('point_with_line_string_cast')->isGeometry()->nullable();
$table->point('point_geography')->nullable();
$table->decimal('longitude')->nullable();
$table->decimal('latitude')->nullable();
Expand Down

0 comments on commit 16a979f

Please sign in to comment.