File tree 2 files changed +25
-16
lines changed 2 files changed +25
-16
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace Grimzy \LaravelMysqlSpatial \Eloquent ;
4
4
5
- use Grimzy \LaravelMysqlSpatial \Types \GeometryInterface ;
6
5
use Illuminate \Database \Eloquent \Builder as EloquentBuilder ;
7
6
8
7
class Builder extends EloquentBuilder
9
8
{
10
- public function update (array $ values )
11
- {
12
- foreach ($ values as $ key => &$ value ) {
13
- if ($ value instanceof GeometryInterface) {
14
- $ value = $ this ->asWKT ($ value );
15
- }
16
- }
17
-
18
- return parent ::update ($ values );
19
- }
20
-
21
- protected function asWKT (GeometryInterface $ geometry )
22
- {
23
- return $ this ->getQuery ()->raw ("ST_GeomFromText(' " .$ geometry ->toWKT ()."') " );
24
- }
9
+ use SpatialBuilderTrait;
25
10
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Grimzy \LaravelMysqlSpatial \Eloquent ;
4
+
5
+ use Grimzy \LaravelMysqlSpatial \Types \GeometryInterface ;
6
+
7
+ trait SpatialBuilderTrait
8
+ {
9
+ public function update (array $ values )
10
+ {
11
+ foreach ($ values as $ key => &$ value ) {
12
+ if ($ value instanceof GeometryInterface) {
13
+ $ value = $ this ->asWKT ($ value );
14
+ }
15
+ }
16
+
17
+ return parent ::update ($ values );
18
+ }
19
+
20
+ protected function asWKT (GeometryInterface $ geometry )
21
+ {
22
+ return $ this ->getQuery ()->raw ("ST_GeomFromText(' " .$ geometry ->toWKT ()."') " );
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments