diff --git a/src/Eloquent/SpatialTrait.php b/src/Eloquent/SpatialTrait.php index e08a476d..da6c2a95 100755 --- a/src/Eloquent/SpatialTrait.php +++ b/src/Eloquent/SpatialTrait.php @@ -104,7 +104,7 @@ public function setRawAttributes(array $attributes, $sync = false) $spatial_fields = $this->getSpatialFields(); foreach ($attributes as $attribute => &$value) { - if (in_array($attribute, $spatial_fields) && is_string($value) && strlen($value) >= 15) { + if (in_array($attribute, $spatial_fields) && is_string($value) && strlen($value) >= 13) { $value = Geometry::fromWKB($value); } } diff --git a/tests/Integration/Models/GeometryModel.php b/tests/Integration/Models/GeometryModel.php index 0b08186a..0565fd35 100644 --- a/tests/Integration/Models/GeometryModel.php +++ b/tests/Integration/Models/GeometryModel.php @@ -9,5 +9,5 @@ class GeometryModel extends Model protected $table = 'geometry'; - protected $spatialFields = ['location', 'line']; + protected $spatialFields = ['location', 'line', 'multi_geometries']; } diff --git a/tests/Integration/SpatialTest.php b/tests/Integration/SpatialTest.php index 415d8557..87f92a2b 100644 --- a/tests/Integration/SpatialTest.php +++ b/tests/Integration/SpatialTest.php @@ -251,6 +251,10 @@ public function testInsertEmptyGeometryCollection() $geo->multi_geometries = new GeometryCollection([]); $geo->save(); $this->assertDatabaseHas('geometry', ['id' => $geo->id]); + + $geo2 = GeometryModel::find($geo->id); + $this->assertInstanceOf(GeometryCollection::class, $geo2->multi_geometries); + $this->assertEquals(0, count($geo2->multi_geometries)); } public function testUpdate()