@@ -36,7 +36,7 @@ protected function performInsert(EloquentBuilder $query, array $options = [])
3636 foreach ($ this ->attributes as $ key => $ value ) {
3737 if ($ value instanceof GeometryInterface) {
3838 $ this ->geometries [$ key ] = $ value ; //Preserve the geometry objects prior to the insert
39- $ this ->attributes [$ key ] = $ this ->getConnection ()->raw (sprintf ("ST_GeomFromText ('%s') " , $ value ->toWKT ()));
39+ $ this ->attributes [$ key ] = $ this ->getConnection ()->raw (sprintf ("GeomFromText ('%s') " , $ value ->toWKT ()));
4040 }
4141 }
4242
@@ -73,12 +73,13 @@ public function getSpatialFields()
7373
7474 public function scopeDistance ($ query , $ distance , $ point , $ column_name ) {
7575 // TODO: check if array, and transform to string delimited by ,
76+ // TODO: what about mysql 5.5? distance_sphere? need test
7677 return $ query
7778 ->whereRaw ("st_distance_sphere(` {$ column_name }`, POINT( {$ point ->getLng ()}, {$ point ->getLat ()})) <= {$ distance }" )
7879 ->whereRaw ("st_distance_sphere(` {$ column_name }`, POINT( {$ point ->getLng ()}, {$ point ->getLat ()})) != 0 " );
7980 }
8081
8182 public function scopeBounding ($ query , Geometry $ bounds , $ column_name ) {
82- return $ query ->whereRaw ("MBRIntersects(ST_GeomFromText (' {$ bounds ->toWkt ()}'), ` {$ column_name }`) " );
83+ return $ query ->whereRaw ("MBRIntersects(GeomFromText (' {$ bounds ->toWkt ()}'), ` {$ column_name }`) " );
8384 }
8485}
0 commit comments