mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-16 17:33:45 +00:00
Add support methods.
This commit is contained in:
@@ -23,8 +23,6 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Repositories\Account;
|
namespace FireflyIII\Repositories\Account;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Exception;
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
|
||||||
use FireflyIII\Factory\AccountFactory;
|
use FireflyIII\Factory\AccountFactory;
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
@@ -98,6 +96,25 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
return AccountType::whereType($type)->first();
|
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
|
* @param Account $account
|
||||||
*
|
*
|
||||||
|
@@ -128,6 +128,16 @@ interface AccountRepositoryInterface
|
|||||||
*/
|
*/
|
||||||
public function getCashAccount(): Account;
|
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
|
* @param Account $account
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user