Expand suppport for new location model in tags.

This commit is contained in:
James Cole 2019-12-30 15:24:52 +01:00
parent 35649bea5c
commit 7e5d0d455a
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
3 changed files with 26 additions and 0 deletions

View File

@ -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,

View File

@ -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();
}
}

View File

@ -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.
*/