Skip to content

Commit 06ca5c5

Browse files
authored
Merge pull request #21 from boryn/patch-1
Update README.md
2 parents ca27447 + 0cbe61f commit 06ca5c5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,16 @@ return [
175175
#### Bulk Operations
176176
In order to insert or update several rows with spatial data in one query using the `upsert()` method in Laravel, the package requires a workaround solution to avoid the error `Object of class TarfinLabs\LaravelSpatial\Types\Point could not be converted to string`.
177177

178-
The solution is to use the `toGeomFromTextString()` method to convert the `Point` object to a WKT string, and then use `DB::raw()` to create a raw query string.
178+
The solution is to use the `toGeomFromText()` method to convert the `Point` object to a WKT string, and then use `DB::raw()` to create a raw query string.
179179

180180
Here's an example of how to use this workaround in your code:
181181

182182
```php
183183
use TarfinLabs\LaravelSpatial\Types\Point;
184184

185185
$points = [
186-
['external_id' => 5, 'location' => (new Point(50, 20))->toGeomFromTextString()],
187-
['external_id' => 7, 'location' => (new Point(60, 30))->toGeomFromTextString()],
186+
['external_id' => 5, 'location' => DB::raw((new Point(lat: 40.73, lng: -73.93))->toGeomFromText())],
187+
['external_id' => 7, 'location' => DB::raw((new Point(lat: -37.81, lng: 144.96))->toGeomFromText())],
188188
];
189189

190190
Property::upsert($points, ['external_id'], ['location']);

0 commit comments

Comments
 (0)