Skip to content

Commit

Permalink
fix: ids in GeoJSON
Browse files Browse the repository at this point in the history
  • Loading branch information
mwargan committed Dec 29, 2023
1 parent 035f282 commit 65c03ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/Http/Resources/MarkerGeoJsonResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public function toArray($request)
$skipProps = [
'x',
'y',
'location'
'location',
'id'
];

// All the rest of the properties available on the model, except the ones we want to skip, should be in an array. For this, we need to get the object as Laravel would provide it, which would hide all the properties we want to skip, as well as all those in $hidden.
Expand All @@ -44,6 +45,7 @@ public function toArray($request)
$this->y,
],
],
'id' => $this->id,
'properties' => [
...$properties
],
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/MarkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public function testSeeAllMapMarkersInGeoJsonFormat()
'type',
'coordinates',
],
'id',
'properties' => [
'id',
'description',
'link',
'elevation',
Expand Down

0 comments on commit 65c03ed

Please sign in to comment.