Add support methods.

This commit is contained in:
James Cole 2018-03-19 08:17:31 +01:00
parent 40787bc29a
commit 552a8e130c
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
2 changed files with 29 additions and 2 deletions

View File

@ -23,8 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Account;
use Carbon\Carbon;
use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\AccountFactory;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
@ -98,6 +96,25 @@ class AccountRepository implements AccountRepositoryInterface
return AccountType::whereType($type)->first();
}
/**
* Return meta value for account. Null if not found.
*
* @param Account $account
* @param string $field
*
* @return null|string
*/
public function getMetaValue(Account $account, string $field): ?string
{
foreach ($account->accountMeta as $meta) {
if ($meta->name === $field) {
return strval($meta->data);
}
}
return null;
}
/**
* @param Account $account
*

View File

@ -128,6 +128,16 @@ interface AccountRepositoryInterface
*/
public function getCashAccount(): Account;
/**
* Return meta value for account. Null if not found.
*
* @param Account $account
* @param string $field
*
* @return null|string
*/
public function getMetaValue(Account $account, string $field): ?string;
/**
* @param Account $account
*