diff --git a/src/GeometryCast.php b/src/GeometryCast.php index 37fcf98..fe60b88 100644 --- a/src/GeometryCast.php +++ b/src/GeometryCast.php @@ -73,6 +73,8 @@ public function set($model, string $key, $value, array $attributes): ?Expression ); } + /** @var Geometry $value */ + return $value->toSqlExpression($model->getConnection()); } diff --git a/tests/Objects/GeometryTest.php b/tests/Objects/GeometryTest.php index 45a17d2..a496c2c 100644 --- a/tests/Objects/GeometryTest.php +++ b/tests/Objects/GeometryTest.php @@ -7,13 +7,13 @@ use MatanYadaev\EloquentSpatial\Enums\Srid; use MatanYadaev\EloquentSpatial\GeometryExpression; use MatanYadaev\EloquentSpatial\Objects\Geometry; +use MatanYadaev\EloquentSpatial\Objects\GeometryCollection; use MatanYadaev\EloquentSpatial\Objects\LineString; -use MatanYadaev\EloquentSpatial\Objects\MultiPoint; use MatanYadaev\EloquentSpatial\Objects\MultiLineString; -use MatanYadaev\EloquentSpatial\Objects\Polygon; +use MatanYadaev\EloquentSpatial\Objects\MultiPoint; use MatanYadaev\EloquentSpatial\Objects\MultiPolygon; -use MatanYadaev\EloquentSpatial\Objects\GeometryCollection; use MatanYadaev\EloquentSpatial\Objects\Point; +use MatanYadaev\EloquentSpatial\Objects\Polygon; use MatanYadaev\EloquentSpatial\Tests\TestModels\TestPlace; it('throws exception when generating geometry from other geometry WKB', function (): void { diff --git a/tests/database/migrations-laravel-<=10/0000_00_00_000000_create_test_places_table.php b/tests/database/migrations-laravel-<=10/0000_00_00_000000_create_test_places_table.php index 66f2b0c..b608cc4 100644 --- a/tests/database/migrations-laravel-<=10/0000_00_00_000000_create_test_places_table.php +++ b/tests/database/migrations-laravel-<=10/0000_00_00_000000_create_test_places_table.php @@ -13,7 +13,7 @@ public function up(): void $table->timestamps(); $table->string('name'); $table->string('address'); - $table->geometry('geometry')->isGeometry()->nullable(); + $table->geometry('geometry')->nullable(); $table->point('point')->isGeometry()->nullable(); $table->multiPoint('multi_point')->isGeometry()->nullable(); $table->lineString('line_string')->isGeometry()->nullable();