Make sure that accounts and tags both can handle locations.

This commit is contained in:
James Cole
2019-12-30 17:43:04 +01:00
parent 7e5d0d455a
commit becab15ab8
13 changed files with 123 additions and 124 deletions

View File

@@ -404,6 +404,23 @@ class TagRepository implements TagRepositoryInterface
$tag->zoomLevel = $data['zoom_level'];
$tag->save();
// update, delete or create location:
$hasLocation = $data['has_location'] ?? false;
if (false === $hasLocation) {
$tag->locations()->delete();
}
if (true === $hasLocation) {
$location = $this->getLocation($tag);
if (null === $location) {
$location = new Location;
$location->locatable()->associate($tag);
}
$location->latitude = $data['latitude'] ?? config('firefly.default_location.latitude');
$location->longitude = $data['longitude'] ?? config('firefly.default_location.longitude');
$location->zoom_level = $data['zoom_level'] ?? config('firefly.default_location.zoom_level');
$location->save();
}
return $tag;
}