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
3 changed files with 26 additions and 0 deletions

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