Skip to content

Firefly III: a personal finances manager

Expand suppport for new location model in tags.

James Cole7e5d0d455a66
diff --git a/.env.example b/.env.example
index d962b83bb1..a95baef321 100644
--- a/.env.example
+++ b/.env.example
@@ -100,6 +100,11 @@ SEND_REPORT_JOURNALS=true
# Set a Mapbox API key here (see mapbox.com) so there might be a map available at various places.
MAPBOX_API_KEY=
+# The map will default to this location:
+MAP_DEFAULT_LAT=51.983333
+MAP_DEFAULT_LONG=5.916667
+MAP_DEFAULT_ZOOM=6
+
# Firefly III currently supports two provider for live Currency Exchange Rates:
# "fixer", and "ratesapi".
# RatesApi.IO (see https://ratesapi.io) is a FREE and OPEN SOURCE live currency exchange rates,
diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php
index 48c77ba72c..c14cecd951 100644
--- a/app/Repositories/Tag/TagRepository.php
+++ b/app/Repositories/Tag/TagRepository.php
@@ -26,6 +26,7 @@ use Carbon\Carbon;
use DB;
use FireflyIII\Factory\TagFactory;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
+use FireflyIII\Models\Location;
use FireflyIII\Models\Tag;
use FireflyIII\Models\TransactionType;
use FireflyIII\User;
@@ -363,6 +364,7 @@ class TagRepository implements TagRepositoryInterface
'tag' => $tag->tag,
'id' => $tag->id,
'created_at' => $tag->created_at,
+ 'location' => $this->getLocation($tag),
];
}
@@ -501,4 +503,12 @@ class TagRepository implements TagRepositoryInterface
$tag->delete();
}
}
+
+ /**
+ * @inheritDoc
+ */
+ public function getLocation(Tag $tag): ?Location
+ {
+ return $tag->locations()->first();
+ }
}
diff --git a/app/Repositories/Tag/TagRepositoryInterface.php b/app/Repositories/Tag/TagRepositoryInterface.php
index d0986822dd..ef0abbc57d 100644
--- a/app/Repositories/Tag/TagRepositoryInterface.php
+++ b/app/Repositories/Tag/TagRepositoryInterface.php
@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Tag;
use Carbon\Carbon;
+use FireflyIII\Models\Location;
use FireflyIII\Models\Tag;
use FireflyIII\User;
use Illuminate\Support\Collection;
@@ -32,6 +33,16 @@ use Illuminate\Support\Collection;
*/
interface TagRepositoryInterface
{
+
+ /**
+ * Return location, or NULL.
+ *
+ * @param Tag $tag
+ *
+ * @return Location|null
+ */
+ public function getLocation(Tag $tag): ?Location;
+
/**
* Destroy all tags.
*/