Skip to content

Commit 16a979f

Browse files
committed
readme fixes
1 parent dbebd7d commit 16a979f

File tree

4 files changed

+24
-10
lines changed

4 files changed

+24
-10
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ composer require matanyadaev/laravel-eloquent-spatial
5757
}
5858
```
5959

60+
* On Postgres, Laravel create spatial columns as `geography` type by default. If you want to use `geometry` type, you can use the `->isGeometry()` method:
61+
62+
```php
63+
$table->point('location')->isGeometry()->nullable();
64+
$table->polygon('area')->isGeometry()->nullable();
65+
```
66+
67+
You can also use the `->projection()` method to set the SRID:
68+
69+
```php
70+
$table->point('location')->projection(Srid::WGS84->value)->nullable(); // 4326 is the default of `geography` type
71+
$table->polygon('area')->isGeometry()->projection(0)->nullable(); // 0 is the default of `geometry` type
72+
```
73+
6074
3. Run the migration:
6175

6276
```bash

docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ services:
1414
restart: unless-stopped
1515
postgres:
1616
container_name: postgres-laravel-eloquent-spatial
17-
image: postgis/postgis:16-2
17+
image: postgis/postgis:16-3.4
1818
environment:
1919
POSTGRES_DB: laravel_eloquent_spatial_test
2020
POSTGRES_USER: root

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ parameters:
88
- src/Factory.php
99
ignoreErrors:
1010
-
11-
message: '#Call to an undefined method Illuminate\\Database\\Schema\\ColumnDefinition\:\:(isGeometry|projection)\(\)#'
11+
message: '#Call to an undefined method Illuminate\\Database\\Schema\\ColumnDefinition\:\:isGeometry\(\)#'
1212
path: tests/database/migrations/*.php
1313
-
1414
message: '#Undefined variable: \$this#'

tests/database/migrations/0000_00_00_000000_create_test_places_table.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ public function up(): void
1313
$table->timestamps();
1414
$table->string('name');
1515
$table->string('address');
16-
$table->point('point')->isGeometry()->projection(0)->nullable();
17-
$table->multiPoint('multi_point')->isGeometry()->projection(0)->nullable();
18-
$table->lineString('line_string')->isGeometry()->projection(0)->nullable();
19-
$table->multiLineString('multi_line_string')->isGeometry()->projection(0)->nullable();
20-
$table->polygon('polygon')->isGeometry()->projection(0)->nullable();
21-
$table->multiPolygon('multi_polygon')->isGeometry()->projection(0)->nullable();
22-
$table->geometryCollection('geometry_collection')->isGeometry()->projection(0)->nullable();
23-
$table->point('point_with_line_string_cast')->isGeometry()->projection(0)->nullable();
16+
$table->point('point')->isGeometry()->nullable();
17+
$table->multiPoint('multi_point')->isGeometry()->nullable();
18+
$table->lineString('line_string')->isGeometry()->nullable();
19+
$table->multiLineString('multi_line_string')->isGeometry()->nullable();
20+
$table->polygon('polygon')->isGeometry()->nullable();
21+
$table->multiPolygon('multi_polygon')->isGeometry()->nullable();
22+
$table->geometryCollection('geometry_collection')->isGeometry()->nullable();
23+
$table->point('point_with_line_string_cast')->isGeometry()->nullable();
2424
$table->point('point_geography')->nullable();
2525
$table->decimal('longitude')->nullable();
2626
$table->decimal('latitude')->nullable();

0 commit comments

Comments
 (0)